15.2 Checksums and Verbose Transfers

15.2 Checksums and Verbose Transfers

The rsync command uses file checksums (near-unique signatures) to determine whether any files on the transfer source are already on the destination.

The first time you transfer an entire directory hierarchy to a remote host, rsync sees that none of the files already exist at the destination, and it transfers everything. Testing your transfer with rsync -n verifies this for you.

After running rsync, try running it again, but this time as rsync -n or rsync -v. This time, no files should show up in the transfer list because an exact copy of the file set exists on both ends, so the file checksums are the same.

However, when the files on the source side are not identical to the files on the destination side, rsync transfers the source files and overwrites any files that exist on the remote side. There are a few options that override this checksum behavior:

  • --ignore-existing Does not clobber files already on the target side.

  • --backup (abbreviation: -b) Does not clobber files already on the target, but rather renames these existing files by adding a ~ suffix to their names before transferring the new files.

  • --suffix=s Changes the suffix used with --backup from ~ to s.

  • --update (abbreviation: -u) Does not clobber any file on the target that has a later date than the corresponding file on the source.

With no special options, rsync operates quietly, only producing output when there is a problem. However, you can use rsync -v for verbose mode, and if you need even more output, rsync -vv gives yet more details. (You can tack on as many v options as you like, but two is probably more than you need.) For a comprehensive summary after the transfer, use rsync --stats.