I wanted to back up a folder and knew rsync was a good candidate for the job. However, rsync has so many options that I was not completely sure which flags to pass along. Luckily this Server Fault answer shed some light on my issue. This post serves mainly as a reminder to future me and regurgitates the answer in question.

Run rsync as follows:

rsync -gloptrunc $SRC $DST

where

  • g: preserves group owner info
  • l: copies symlinks as symlinks
  • o: preservers owner info
  • p: preserves permissions
  • t: preserves timestamps
  • r: recurses through directories
  • u: updates, i.e., only copy newer files
  • n: no, do a dry run (remove this one when you want something to happen)
  • c: checksum on file blocks when possible, ignored on local file systems where the files are just copied

As the answer states, you can remember this as two “words”: glop and trunc. You can optionally add the v flag to make rsync verbose and state the files it is copying.

The $SRC directory is considered the master. No deleting is done on either side, but overriding does happen.