rsyncing files from a server to a client

Memory jogger for me mainly, but useful

How to make rsync copy files from one computer to another BUT not overwriting existing local files.

The magic keyword is --ignore-existing

Merge/continue copying files from one machine to another with checksum

NOTE: Checksumming is slow!

By default rsync will check the destination files modified time and size. This is great for the most part, but sometimes this isn't enough. A recent use case was recovering from a partially completed file transfer on a pre allocated sparce filled file. Size was good, data was all 0's.

rsync has the -c, --checksum command that checks by calculating a checksum of both files before deciding if it needs to copy.

-c, --checksum skip based on checksum, not mod-time & size
--ignore-existing skip updating files that exist on receiver

rsync --ignore-existing -c -P -u -i -r -a -vv -e "ssh -l MY_USERNAME" --delete SOME.SERVER.COM:/SRC_DIR DEST_DIR

In order:

--ignore-existing skip updating files that exist on receiver
-c, --checksum skip based on checksum, not mod-time & size
-P same as --partial --progress
-u, --update skip files that are newer on the receiver
-i, --itemize-changes output a change-summary for all updates
-r, --recursive recurse into directories
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-e, --rsh=COMMAND specify the remote shell to use
--delete delete extraneous files from dest dirs

-P turns on nice output
-u keeps our file if it is newer
-i gives a nice output of what (if any) changes are happening
-r is obviously important as you need to recurse dirs
-a just turns on a load of useful flags. NOTE there is no -H so it will recurse hardlinks!
-e runs an ssh connection from the destination to the source to tunnel the data
--delete deletes files on the destination that are not in the source. NOTE this could delete stuff!

Ending Credits
Don't use -c if you want speed but no guarantee of data integrity
--ignore-existing is useful to make sure you are not clobbering data