rsync -avz /MyLocalFolder/ root@myremotemachine:/MyBackUpFolder/
The above command will transfer all files in MyLocalFolder to MyBackUpFolder on a Remote machine named myremotemachine using user name as root.
2. If you want to Update the Remote machine folder so that any files that are moved from Local Folder are also deleted from the Remote machine then simply use --del. Here is an example:
rsync -avz --del /MyLocalFolder/ root@myremotemachine:/MyBackUpFolder/
3. Copy not just the files under a directory but also the parent directory name should be copied and created on the server... To achieve this just drop the / after MyLocalFolder in example 1. Basically the command would look like:
rsync -avz /MyLocalFolder root@myremotemachine:/MyBackUpFolder/
The command will first create a folder named MyLocalFolder within MyBackUpFolder on remote machine and then transfer files.
4. To Specify multiple directories that need to be transferred use it like:
rsync -avz /MyLocalFolder1 /MyLocalFolder2 root@myremotemachine:/MyBackUpFolder/
5. To Transfer files from Remote Server to Local machine just change the order of Source and Destinations... See below:
rsync -avz root@myremotemachine:/MyBackUpFolder/ /MyLocalFolder
Note:
v = verbose - means that it prints on the screen what is being copied
a = archive - means that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer
z = compress - compress file data