rsync is a unix command line tool for syncing two folders. It can sync locally or over the network using SSH.

Usage:

rsync -arvu --dry-run --delete "/path/to/source" "/path/to/destination"

This will sync the entire source folder into destination. If you want to sync the contents of source, you need to use a trailing slash, like so "/path/to/source/"

Some flags:

  • -a, --archive Archive mode (Do the sync preserving all filesystem attributes)
  • -v, --verbose run verbosely
  • -r, --recursive run recursively
  • -t, --times run recursively
  • -u, --update only copy files with a newer modification time (or size difference if the times are equal)
  • -c only copy files with a different checksum (this could be helpful when there are changes of -u not giving the desired results. But since it generates a 128-bit md4 hash of the file it will take longer than -u)
  • -L, --copy-links transform symlink into referent file/dir
  • --delete delete the files in target folder that do not exist in the source
  • --dry-run will give us the output, but not do the actual sync. Perfect for testing commands before you commit to it

Modified from https://unix.stackexchange.com/a/203854 and man rsync