Rsync is a very handy tool at synchronizing the contents of two folders/directories. And while being great for local folders, it also works remotely, via SSH, thanks to the -e ssh parameter:

# rsync -ave ssh sourceserver:/home/user/ /home/user/

will sync /home/user from the sourceserver with /home/user on the local machine.

By default, rsync will only copy files and directories, but not remove them from the destination copy when they are removed from the source. To keep the copies exact, include the –delete flag:

# rsync -ave ssh --delete sourceserver:~/myfiles .

Full list of accepted source | destination pairs:

Usage: rsync [OPTION]... SRC [SRC]... DEST
or   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST
or   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST
or   rsync [OPTION]... SRC [SRC]... rsync://[USER@]HOST[:PORT]/DEST
or   rsync [OPTION]... [USER@]HOST:SRC [DEST]
or   rsync [OPTION]... [USER@]HOST::SRC [DEST]
or   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST]
The ':' usages connect via remote shell, while '::' & 'rsync://' usages connect
to an rsync daemon, and require SRC or DEST to start with a module name.

Leave a Reply