Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is a way to tell rsync to only apply changes (delete, overwrite, create) only if all files in the file list transferred successfully.

Just to clarify, this would essentially be putting a transaction around the transfer.

share|improve this question
up vote 3 down vote accepted

you could use a filesystem (btrfs, zfs) with snapshot-features:

  • snapshot your current state
  • rsync
  • check exit code of rsync and rollback if needed

you can also enroll your own snapshots:

  • make a copy of the files (this becomes the working area)
  • rsync to the working area
  • check exit code of rsync and move working area over the original files if exit code was ok.
share|improve this answer
Instead of copies, you may want to use hard links to save time and space. – Ryan Thompson Nov 15 '10 at 4:12

From the 'rsync' man pages, you may be in luck only for deletes:

Some options require rsync to know the full file list, so these options disable the incremental recursion mode. These include: --delete-before, --delete-after, --prune-empty-dirs, and --delay-updates. Because of this, the default delete mode when you specify --delete is now --delete-during when both ends of the connection are at least 3.0.0 (use --del or --delete-during to request this improved deletion mode explicitly). See also the --delete-delay option that is a better choice than using --delete-after.

share|improve this answer
That would satisfy deletes, however, I still need it to work for all files just in case there is packet loss or connection interruption. Great answer though. Thanks. – Tres Nov 16 '10 at 4:10

You could use the --delay-updates option, or if you want really atomic updates, the atomic-rsync script (included in Debian as /usr/share/doc/rsync/scripts/atomic-rsync.gz).

share|improve this answer
I'm actually using the --backup option now and checking to see if the rsync fails. If so I attempt to restore the backup. Nothing much you can do if the network craps out and you can't connect to restore the backup. Pretty small chance though ;) – Tres Nov 18 '10 at 10:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.