Skip to content

Instantly share code, notes, and snippets.

@sinewalker
Last active March 28, 2018 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinewalker/9fb8be2034891a21d50a21d3398c193b to your computer and use it in GitHub Desktop.
Save sinewalker/9fb8be2034891a21d50a21d3398c193b to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment