Rsync is a great command for keeping large directory structures aligned across different machines/drives.
Yes you could just do a backup and a restore, but this is inefficient when only 1 file has changed.
My normal Rsync command
When dealing with Unix to Unix (Including Mac) I usually use this command
rsync -xav <from> <to>
From / To
The From/To settings are swappable meaning you can sync in both directions, what some people have issues with at times is specfying the values of From/To.
I want to move data from Server SVR1, from user Bob, And I only want Bob's data directory to my currect directory
rsync <flags> Bob@Svr:/home/Bob/data data
rsync <flags> Bob@Svr:~/data data
Special ssh ports
Of course some people have a slightly more paranoid view of the world and run ssh on non-standard ports (a good idea).
At this point the standard rsync command needs to be altered.
rsync -xavn -e "ssh -p <ssh_Port>" <from> <to>
Unix to Windows
Sometimes I need to move data from a Linux environment to a Windows env, here I do have some issues. Becuase rsync tries to set the groups.
I am assuming here that the Windows env is using a Fat or FAT32 formatted disk.
rsync -rltzuv <from> <to>
#What the -a Means
The -a is a shortcut for "-a" which is just shorthand for all of "-rlptgoD"
- r Recursive
- l Links
Too much copying
Rsync at times can see to copy too many files - this is especially true if the target OS does not have the same file security options as the source. In which case this option may be best.
rsync --size-only --progress --ignore-times --exclude-from my_exclude.file
Here we are only checking the size of the file, plus I am using an exclude file.
The exclude file looks like this
2010/* 2011/* 2012/* 2013/* 2014/* 2015/*