rsync Command: Tutorial & Examples

Synchronize files between two systems

The rsync command is a Linux utility that is used to synchronize files and directories between two locations. It stands for "remote sync."

rsync is a powerful tool that allows you to efficiently transfer files and directories between two locations, such as between two local directories or between a local directory and a remote server. It is particularly useful for transferring large files or large numbers of files, as it is able to efficiently transfer only the differences between the source and destination files, rather than transferring the entire file each time.

To use the rsync command, you will need to specify the source and destination locations, as well as any options that you want to use. For example, to synchronize the contents of the src directory with the dst directory, you might use the following command:

rsync -av src/ dst/

In this example, the -a option tells rsync to operate in "archive" mode, which preserves the file permissions, ownership, and timestamps of the source files. The -v option tells rsync to run in verbose mode, which displays a list of the files as they are transferred.

There are many other options available to the rsync command, including options for filtering files, specifying how to handle symlinks, and controlling the transfer rate. You can use these options to fine-tune the behavior of rsync to suit your needs.

To use rsync to transfer files between a local machine and a remote server, you will need to specify the remote server's IP address or domain name and the path to the directory on the remote server that you want to synchronize with. For example, to synchronize the src directory on your local machine with the dst directory on a remote server with the IP address 123.456.789.101, you might use the following command:

rsync -av --bwlimit=1024 src/ 123.456.789.101:dst/

In this example, --bwlimit option specifies a maximum transfer rate of 1024KB/s.

It's important to note that you will need to have access to the remote server in order to use rsync to transfer files to it. This usually requires that you have an account on the remote server and that you are able to connect to it using SSH.

rsync is a useful tool for synchronizing files and directories, and it is available on most Linux distributions.

Except where otherwise noted, content on this site is licensed under a CC BY-SA 4.0 license CC BY SA