USING RSYNC TO BACKUP AND RESTORE
SYNC From local to remote computer
rsync -avz --delete /source/folder user@remote.server:/destination/folder
SYNC From remote to local computer
rsync -avz --delete user@remote.server:/source/folder /destination/folder
The --delete option will delete the files in the destination folder, that have been deleted in the source folder, that way the two folders will always be in sync.
NOTE: If you need to limit bandwidth used from in a rsync backup connection use --bwlimit=KBPS and tell rsync how much bandwidth in Kbytes pers second can be used.
BACKUP /var/www from 10.6.56.245 to 10.6.56.100 (ftp server)
RESTORE /var/www from 10.6.56.100 to 10.6.56.244
-------------------------------------------------------------------------
COPY From local to remote
rsync --progress --partial -avz /folder/to/copy/ user@remote.server:/remote/folder
NOTE: This will copy all files in /folder/to/copy/ to /remote/folder in the remote server, the folder copy itself will not be created in the remote computer, and only its contents will be copied, if you want the folder itself to also be created and then its contents copied inside the newly created copy folder, use this command.
rsync --progress --partial -avz /folder/to/copy user@remote.server:/remote/folder
NOTE: the trailing slash after copy that makes the difference. The rest of options are:
• progress: will show the percentage of the file copied
• partial: tells rsync to keep the partial file which should make a subsequent transfer of the rest of the file much faster.
• a: Archive, It is a quick way of saying you want recursion and want to preserve almost everything.
• v: Verbose
• z: Compress the files so less bandwidth is needed, and the files are copied faster.