Stop rsync from wrecking your remote space with invisible temp files
Backup & Recovery (Rsync/Tar/Dd)
Stop rsync from wrecking your remote space with invisible temp files
🧩 The Challenge
Everyone thinks rsync is smart enough to handle partial files, but if your connection drops halfway through a massive sync, you’re often left with a graveyard of partially-written debris on the destination. I’ve spent way too much time manually cleaning up broken file fragments after a late-night server migration went sideways.
💡 The Fix
You need to tell rsync to use a specific hidden directory for temporary files that gets cleaned up automatically if the transfer fails. It keeps your production storage clean and stops those half-baked files from causing app errors.
rsync -av --partial-dir=.rsync-tmp /local/data/ user@remote:/destination/
⚙️ Why It Works
Setting a partial directory tells rsync to stage incomplete chunks in a safe place until the transfer is fully verified, instead of dumping them directly into your live directory. Once the job succeeds, the bits are moved to their final home.
🚀 Pro-Tip: Add –delay-updates to that command if you want the final move to happen all at once, which prevents anyone from reading a file that’s still being written.
Linux Tips & Tricks | © ngelinux.com | 7/23/2026
