From 3f0c429d469965ae32b9fcab80b124a11f73cce7 Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Tue, 26 May 2026 19:55:33 +0000 Subject: [PATCH] offsite-sync: add `|| true` to Step 2 HDD grep|while pipeline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirrors the SSD section's pattern. If the LAST iteration of the `while IFS= read -r f; do [ -f "$f" ] && echo "${f#/srv/nfs/}"; done` body sees a file that was deleted between inotify capture and now (e.g. an immich encoded-video temp file that got cleaned up), the while loop returns 1, pipefail propagates, set -e kills the script silently before reaching the rsync. No log line, just disappears. Pre-existing bug; only exposed today after pruning the bypass regex to immich-only — when the regex was broader, the last match in the sorted dedup'd inotify log happened to be a live file often enough that the bug stayed dormant. Validated by full e2e run: 1120 nfs/immich files + 2285 nfs-ssd files shipped successfully. Co-Authored-By: Claude Opus 4.7 --- scripts/offsite-sync-backup.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/offsite-sync-backup.sh b/scripts/offsite-sync-backup.sh index 85e4134c..790215e1 100644 --- a/scripts/offsite-sync-backup.sh +++ b/scripts/offsite-sync-backup.sh @@ -132,9 +132,14 @@ elif [ -s "${NFS_CHANGE_LOG}" ]; then sort -u "${NFS_CHANGE_LOG}" > /tmp/nfs-changes-deduped # HDD NFS — include only /srv/nfs/immich/ paths. + # `|| true` is REQUIRED: if the last iteration's `[ -f "$f" ]` is false + # (file was deleted between inotify capture and now — e.g., immich + # encoded-video temp file that got cleaned up), the while loop returns + # 1, pipefail propagates, and `set -e` kills the script silently before + # reaching the rsync. Matches the SSD section's pattern below. grep -E "${NFS_SDA_BYPASS_RE}" /tmp/nfs-changes-deduped | \ while IFS= read -r f; do [ -f "$f" ] && echo "${f#/srv/nfs/}"; done \ - > /tmp/sync-nfs.list 2>/dev/null + > /tmp/sync-nfs.list 2>/dev/null || true NFS_COUNT=$(wc -l < /tmp/sync-nfs.list 2>/dev/null || echo 0) if [ "${NFS_COUNT:-0}" -gt 0 ]; then rsync -rlt --files-from=/tmp/sync-nfs.list /srv/nfs/ "${NFS_DEST}/" 2>&1 \