loading
img-bg

How to use rsync? homepage - How to use rsync?

When to use rsync

The rsync program enables you to synchronize directories locally or between two computers. Rsync automatically determines which files are different or new between the two locations, and then synchronizes the directories. You can use this functionality to accomplish a number of tasks. For example, you can use rsync to back up your web site to another computer. Alternatively, suppose that you have a web site development environment already installed on another server. You could use rsync to deploy this environment to your Hostiso Hosting account.
If you are synchronizing directories between two separate computers, they both must have rsync installed.

How to use rsync

The rsync program has many features, but the following command-line options are enough to get started: Using these rsync options, we can go through some examples. Suppose you want to back up your web site files to another server. To do this, follow these steps:
  1. Log in to your account using SSH.
  2. To make sure you are in your home directory, type the following command:
    cd ~
  3. To back up (or “push”) your public_html directory to the user account on a remote server at example.com, type the following command:
    rsync -avz -e ssh public_html user@example.com:~/backup
    This command assumes that the remote server is running SSH on port 22. If you were backing up to another Hostiso Hosting server, for example, you would use the following command because SSH runs on port 7822:
    rsync -avz -e "ssh -p7822" public_html user@example.com:~/backup
  4. After rsync finishes, the user on the remote server at example.com has a backup/public_html directory in their account that is an exact copy of the public_html directory in your account.
Another common scenario is “pulling” files from a remote location. For example, you may have a development environment set up on a remote server. You could use rsync to pull files from the remote repository into your Hostiso Hosting account. With each subsequent “pull”, rsync will only update the files that have changed since the last update, thereby saving time and bandwidth. To do this, run the following command from your home directory:
rsync -avz -e ssh user@example.com:~/public_html .
After rsync finishes, your public_html directory contains a copy of the files in the remote server’s public_html directory.

More Information

This article is only a brief introduction to rsync‘s extensive capabilities. To view the official online documentation for the rsync program, please visit http://rsync.samba.org/documentation.html.