Stop tar from dying when you hit a locked system file

Backup & Recovery (Rsync/Tar/Dd)

Stop tar from dying when you hit a locked system file

🧩 The Challenge

You finally get around to archiving that directory, but tar barfs halfway through because some log file got rotated or a lock file appeared mid-stream. I’ve wasted an entire afternoon babysitting a backup only for it to exit with a non-zero status because of one stupid temporary file.

💡 The Fix

Tell tar to stop being so dramatic about file changes and just keep moving. It’ll finish the job instead of bailing out the second it runs into a moving target.

tar --ignore-failed-read --warning=no-file-changed -cvzf backup.tar.gz /path/to/data

⚙️ Why It Works

By ignoring the failed reads, you keep the process alive when files disappear or become inaccessible while you’re scanning them. It transforms the exit status from a hard stop into a nuisance you can handle later.

🚀 Pro-Tip: Add the –exclude flag to skip your logs entirely so you stop backing up trash you don’t even need.

Linux Tips & Tricks | © ngelinux.com | 8/9/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted