my cheat sheet on rsync
Nasser M. Abbasi, April 26, 2012
When on Linux
Suppose I have the master tree like this
and wanted to make sure that my backup tree, located at /home/me/backup/data/ is an exact copy.
so that the result is
The command is
rsync -atrv --delete data /home/me/backup
Another case, is when I want to backup everything below data, but not the directory data itself.
For example, using the above source tree, I wanted the result to be
Then the command is
rsync -atrv --delete data/ /home/me/backup
Notice the difference is the use of the / at the end of data.
So, if to include the directoy data and evertyhing thing below it, then use
data in the command. But to only backup everything inside data then use data/
When on windows using cygwin
Start cygwin shell. Do not right-click and choose "run as adminstrator" but
just click shell so that it runs as same user as me
Now, to backup the folder G:/data to L:/data then the command is
rsync -apvtr --delete --chmod=ugo=rwX data/ /cygdrive/L/data/
Notice the use of "/" above. Also the use of chmod. If I do not
use this, then all the files on L:/data/ will have permissions that
does not allow me to read them. The fixes this. Credit for this
trick is due to this post