Rsync Flags for Folder Backup
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 infol: copies symlinks as symlinkso: preservers owner infop: preserves permissionst: preserves timestampsr: recurses through directoriesu: updates, i.e., only copy newer filesn: 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.