sinewalker
3/16/2018 - 3:47 AM

Rsync source -> dest *properly*

Rsync source -> dest properly

What to run:

rsync -HPva --delete <source>/ <dest>/

(tip for remembering: "Arr! Sync! Hey, Pretty view, eh? Do Eet")

why:

  • -H (--hard-links) sync any hard links as hard links, as distinct from files, at the destination
  • -Pv (--partial --progress --verbose) gives you a nicely verbose output with a reasonable way to estimate remaining time (sometimes)
  • -a (--archive) "equals -rlptgoD", that is "please just work"
  • --delete removes files from the destination that are not present on the source (it doesn't delete from the source)

Notes:

  • running rsync multiple times will pull file metadata in to VFS cache, making subsequent runs much faster (good for priming before an outage)
  • put trailing slashes on <source> and <dest>ination paths to ensure directories are created the way you expect

Sometimes good option:

  • -z (--compress)
    • good if you're transferring over the internet or narrow-band medium
    • bad on localhost