How to Transfer Files and Folders with Rsync over SSH? Linux

Rsync can be used to transfer files and directories over SSH between systems on the network. The most popular protocols are SSH and FTP. FTP is a popular protocol and SSH is the most secure way to transfer files.

SCP and SFTP are some of the tools that are available to transfer files over SSH, but none of them has all the features that rsync provides. Rsync can be used to mirror, incremental backups, copying files between systems

The following steps show how to transfer files and folders with rsync over SSH protocol.

Install rsync utility

               CentOS and Fedora-based OS

               # yum install rsync

               Ubuntu and Debian based OS

               $ Sudo apt install rsync

We need to ensure we have SSH access for the remote server. The remote SSH user must have appropriate access rights to read and write files and folders.

Transfer a single file

               # rsync –a /opt/<single file> <username>@<IP Address>/<path where you need to copy the file>

For Eg:

               # rsync =a /opt/file.zip tom@192.168.1.8:/var/www

The –an option in the command stands for archive mode and allows you to sync directories recursively, transfer special and block devices, preserve symbolic links, modification time, group, ownership and permission.

Transfer files from remote to local

# rsync -a tom@192.168.1.8:/var/www/file.zip /opt/

If SSH on your remote server is listening to a port other than the default port 22, we need to specify the custom port with the rsync command

# rsync -a -e “ssh -p 3322” /home/tom/images/ tom@1192.168.1.8:/var/www/images/

Transferring a large amount of data requires you to monitor the progress. The rsync command in screen mode or with a –P option will show you the progress of the transferred files.

At Velan, our server support engineers can help you to copy a large amount of data from one server to another using rsync command. We troubleshoot problems like these for our clients every day. If you are interested in our service, please fill the Quick connect form to get in touch with us

Credentials

Quick Connect With Us