Stop your tar backups from failing when files vanish mid-stream
Backup & Recovery (Rsync/Tar/Dd)
Stop your tar backups from failing when files vanish mid-stream
🧩 The Challenge
You ever run a nightly tarball of a busy web directory only to have it exit with a non-zero status because some temp log file got rotated while you were reading it? It ruins your automation scripts and leaves you questioning if the backup actually captured the important stuff.
💡 The Fix
Adding the ignore-failed-read flag tells tar to just keep going and ignore those annoying little race conditions. You’ll get a clean exit code and a backup that actually finishes instead of dying on a trivial error.
tar --ignore-failed-read -czf backup.tar.gz /path/to/web/data
⚙️ Why It Works
By default, tar treats a file disappearing or changing during read as a hard stop, but this flag demotes those errors to simple warnings that don’t trigger a failure status. It’s the difference between a successful cron job and waking up to an alert that your backup failed over a junk file.
🚀 Pro-Tip: Pipe your stderr to /dev/null if you really don’t want to see the warning spam, but definitely check the exit code anyway.
Linux Tips & Tricks | © ngelinux.com | 8/12/2026
