In today’s digital world, efficient file transfer is essential, especially when working with big amounts of data. A strong solution for quick and safe file transfers is provided by Rsync with SSH (safe Shell). Here you will get the process of using Rsync over SSH to ensure quick and secure file transfers. Master the art of synchronizing local and remote directories with Rsync, a powerful tool that ensures efficient data management across different systems while minimizing bandwidth usage.

Whether you’re a developer syncing codebases or a system administrator moving backups. Rsync is an acronym meaning “Remote Sync, you can synchronize. Transfer data between various workstations and folders with the rsync program.

You can safely copy your files to another location by employing the Secure Shell (SSH) protocol. Comparing the rsync tool to other ways of copying files, there are several advantages. While sending and receiving files, it employs both compression and decompression. The utility only sends new or updated files. That reduces bandwidth usage and speeds up transfer times.

Check the Installation of Rsync

To operate extensive volumes of data and resources basically, new directories are been created. Coming back, Rsync is included by default in most modern Linux distributions. Run the installation command to see if rsync is already installed on your system.

Use apt-get for Debian and Ubuntu computers:

sudo apt-get install rsync

The result displays the most recent iteration of the tool if rsync is already installed.

checking if rsync installed on ubuntu

Use this on computers running CentOS that use RPMs:

sudo yum install rsync

Transferring Files over SSH and Rsync

Make sure you can use SSH to connect to a remote server before you start moving files and directories with rsync over SSH. You can start backing up your data after it has been validated. Make sure the system at your destination has enough storage. The rsync command’s syntax for copying files over SSH to a remote server is:

rsync OPTION SourceDirectory_or_filePath user@serverIP_or_name:Target

Command Examples for Rsync

See examples of the most typical rsync use cases by reading the rest of the tutorial. Use Rsync to Send a Specific File. Enter the complete source file’s path to send a single file to a distant workstation. For instance:

rsync ~/Dir1/source.pdf test@192.168.56.100:~/Desktop/test

For files with spaces in the name, be careful to use quotations. For instance:

rsync ~/Desktop/Dir1/"source pdf sample.pdf" test@192.168.56.100:~/Desktop/test

Using Rsync, Move Directory Contents

When using rsync over SSH to sync directory contents, you have a few choices. Enter: to move all files from a source directory to a target directory on a remote host.

rsync ~/SourceDirectory/* username@192.168.56.100:~/Destination

The utility is instructed to include all files in the source directory by the asterisk (*). The transfer of subdirectories is not done.

transfer contents of directory with rsync

The output displays the directories that rsync skipped during the transfer.

You can use the -r (recursive) or -a (archive) option to include all subdirectories from the source directory. We advise using the -a flag. This option syncs recursively while preserving all file and permission settings. Use the asterisk in the source path no longer this time.

rsync -a ~/Desktop/Dir1/ test@192.168.56.100:~/Desktop/test

Rsync moves all files and subdirectories from the source directory to the target location when you run the command in this format. Using our previous example, once the transfer is finished, the test folder will have everything from the Dir1 source.

Check out our tutorial on using the rsync command to exclude files and directories from data transfer.

rsync -a ~/Desktop/Dir1 test@192.168.56.100:~/Desktop/test

The Dir1 directory and the remaining files in Dir1 are found when we access the test directory.

Track the Progress of the Rsync File Transfer

Use the -P option to view the status of rsync transfers. This option shows the names of the synchronized files and directories along with the transfer times.

-P continues your transfers if your sync is interrupted due to a problem with your connection. Use the following command to sync recursively and verify the transfer’s status:

rsync -aP ~/SourceDirectory/ username@192.168.56.100:~/Destination

run command to sync and check the status transfer

The transfer is not made if you issue the same command again when the source directory has not changed. The cause is that rsync only exchanges newly created files and modified files. The output in this instance merely displays the following line:

running rsync command to check change

Rsync recognizes changes even in a single source file and syncs them with the target. We modified one file and then executed the same command once more:

output for rsync command a new file to transfer

The result indicates that we moved the source sample2 file after rsync recognized that we had updated the file.

Final Words on How to Transfer Files with Rsync over SSH

The secret to effective and safe data transfer with Rsync over SSH. It can be found in perfecting this technique. You now have the skills necessary to correctly set up and carry out these transfers thanks to this guide. The capabilities of Rsync combined with the security of SSH. It has proven invaluable for maintaining directory structures and minimizing data loss.

Now that the security and integrity of your data are guaranteed. You may confidently streamline your file transfer chores. You should be able to use rsync over SSH file transfer with the Linux commands in this manual. We provided a list of the most popular rsync options. So you may successfully backup your data to a distant place