Rsync command can be launched in one of two ways – this gives the option of 3 different ways to launch rsync transfer, here is how. rsync command can be used as a client with “rsync” (sans daemon) or as an rsync daemon with “rsync –daemon“. The rsync client can launch 3 different transfer types: regular file or folder transfers like cp, or launch a transfer session over ssh, or launch an rsync session over rsync port 873 — rsync daemon can start an rsync server which waits for connections and can receive or send rsync transfer. Any rsync transfer can send 1 or many files or folders. Any rsync transfer can source or target a local file or a remote file.

Good articles:

* https://download.samba.org/pub/rsync/rsync.html (applies to both)
* https://download.samba.org/pub/rsync/rsyncd.conf.html (applies to daemon)

 

(1) RSYNC FILE TRANSFER

Requirement: apt-get install rsync  on the server

To do an RSYNC file transfer its as simple as having rsync simply installed on the server

Commands:

rsync <options> <local source file> <local destination file>

 

(2) RSYNC OVER SSH

Good Articles:

* http://www.cyberciti.biz/tips/linux-use-rsync-transfer-mirror-files-directories.html
* https://www.digitalocean.com/community/tutorials/how-to-copy-files-with-rsync-over-ssh

Requirement:  apt-get install rsync openssh-client openssh-server  on source and destination

To do an RSYNC over SSH files transfer you must have RSYNC and SSH installed on both destination and source box and you must also have IP connectivity between source and destination (so that they can ping each other and more importantly talk to each other on the SSH port which is tcp 22, but you can change that number):

Commands:

rsync <options> <local source file> user@destination:/full/path/

rsync <options> <local source file> destination:/full/path/

Note the above command format shows copying a local file to a remote destination, but you can flip it and copy a remote file over to a local location.

If you dont put in a /full/path then the file would copy to the home directory of the user your using (if you dont specify a user it will just assume to use the same username as the one on the local machine). Everything is relative to the home path of the ssh user.

 

(3) RSYNC DAEMON also known as RSYNC SERVER

Good Articles:

* http://transamrit.net/docs/rsync/
* http://www.jveweb.net/en/archives/2011/01/running-rsync-as-a-daemon.html
* http://www.togaware.com/linux/survivor/Rsync_Server.html

Requirement: apt-get install rsync  on both servers

The other way to use RSYNC is with an RSYNC DAEMON. It requires having an RSYNC SERVER setup on the destination or source side (it doesnt matter which side). The RSYNC SERVER or RSYNC DAEMON is configured with a “samba” like configuration file. For more information on this check this out: https://download.samba.org/pub/rsync/rsyncd.conf.html 

Here is an example of an rsync configuration on a server, this works if your pointing transfer away and to it (so it works both as destination and source):

Note: that you can comment things with # and that the config looks similar to SAMBA configuration (after all they are made by the same people)

This server can be launched like this:

Here is another example of a config (very simple one from a ReadyNAS 4.x):

Here is how the rsync server looks like from netstat view:

Commands:

rsync <options> <local source file> rsync://user@destination/share/file

rsync <options> <local source file> user@destination::share/file

Note:  In the above command format the copy is from local source file to a remote rsync server location. However the source file can be from a remote location and you could be copying it locally

Note: With RSYNC OVER SSH the format is user@destination:/full/path, but with RSYNC SERVER the format is user@destination::sharename

Everything copies to or from the specified shares in this mode. So in the above example 1 server config we need to specify “Backups” in the share field of the command and copy only to or from Backups like so.

Bonus Topic Copying into a folder or over a folder

Summary

The end

Leave a Reply

Your email address will not be published. Required fields are marked *