rsync is a free software computer program for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.
rsync can copy or display directory contents and copy files, optionally using compression and recursion.
The general form used for command line rsync is as follows:
rsync [options] [path to source file] [alternate port] [user_name@remote_host]:[path to destination file]
To copy a file from a local machine to a remote machine using alternate port 1234 - you would use the following:
rsync -aze 'ssh -p 1234' /home/user_name/file_name email@example.com:/home/user_name/directory_name
In this case the file on the local machine (file_name) will be saved on the remote machine in the location /home/user_name/directory_name/file_name To copy a directory from a local machine to a remote machine using alternate port 1357 - you would use the following:
rsync -aze 'ssh -p 1357' --delete /path_to_directory/ firstname.lastname@example.org:/explicit_path_to_location_to_be_saved
In this case the --delete option was used. This essentially deletes anything on the remote machine that doesn't exist on the local machine. Extra care should be used when invoking this option.
- recursive, archive mode (you want to preserve almost everything).
- use compression.
- rsh command (allows you to use SSH).
- This tells rsync to delete extraneous files from the receiving side (ones that aren't on the sending side), but only for the directories that are being synchronized.
- Verbose mode, this option increases the amount of information you are given during the transfer. By default, rsync works silently. A single -v will give you information about what files are being transferred and a brief summary at the end. Two -v flags will give you information on what files are being skipped and slightly more information at the end.
- 'ssh -p PORT'
- This specifies an alternate TCP port number to use rather than the default of 873.
For more information, you can always consult the following man page(s):
- man rsync