Differences

This shows you the differences between two versions of the page.

Link to this comparison view

rsync [2014/04/19 15:41] (current)
Line 1: Line 1:
 +====== rsync ======
 +
 +Bare minimum needed to do backups:
 +
 +<code bash>
 +rsync -azv /source_dir /dest_dir
 +</​code>​
 +
 +The flags are:
 +
 +  * ''​-a'':​ archive mode, which means copying recursively preserving file attributes such as timestamp and owner. This is what allows ''​rsync''​ to be super fast in subsequent executions.
 +  * ''​-z'':​ compress (I wonder if this option makes any sense when the destination folder is in an external hard drive)
 +  * ''​-v'':​ verbose.
 +
 +===== Will it create a directory in the destination?​ =====
 +
 +Writing the source directory without a trailing slash means copying the source directory as a whole into dest_dir. A directory named /​dest_dir/​source_dir will exist after executing rsync.
 +
 +<code bash>
 +rsync -azv /source_dir /dest_dir
 +</​code>​
 +
 +Adding a trailing slash after the source directory changes rsync'​s behaviour to copying the contents within /​source_dir,​ so the contents of /source_dir and /dest_dir will be the same, but source_dir itself won't be created in the destination.
 +
 +<code bash>
 +rsync -azv /​source_dir/​ /dest_dir
 +</​code>​
 +