Stop worrying about rsync hanging on file lock errors

Backup & Recovery (Rsync/Tar/Dd)

Stop worrying about rsync hanging on file lock errors

🧩 The Challenge

You know that feeling when you kick off a massive sync job before leaving for the night, only to find it choked on a bunch of open database files the next morning? It’s infuriating to realize your entire backup set failed just because a few logs were locked by a busy service.

💡 The Fix

Use the rsync exclusion flags to skip those volatile files automatically so your sync actually finishes. It keeps the transfer stream clean and lets you sleep without checking the console at 3 AM.

rsync -av --exclude={'/var/lib/mysql/*','/var/log/*.log'} /source/ /backup/

⚙️ Why It Works

Adding the –exclude flag tells the process to drop those specific items from the file list before it even tries to touch them. By doing this, you prevent the transfer from throwing a tantrum over files that were never meant to be copied while the database is spinning.

🚀 Pro-Tip: Use a text file with –exclude-from=files.txt if you have a massive list of exclusions so you don’t clutter your command history.

Linux Tips & Tricks | © ngelinux.com | 10/19/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted