-
Book Overview & Buying
-
Table Of Contents
Ubuntu Server Cookbook
By :
In this recipe, we will learn how to use the Rsync utility to synchronize files between two directories or between two servers.
Follow these steps to synchronize files with Rsync:
Set up key-based authentication between source and destination servers. We can use password authentication as well, which is described later in this recipe.
Create a sample directory structure on the source server. You can use existing files as well:
ubuntu@src$ mkdir sampledir ubuntu@src$ touch sampledir/file{1..10}
Now, use the following command to synchronize the entire directory from the source server to your local system. Note the / after sampledir. This will copy contents of sampledir in the backup. Without /, the entire sampledir will be copied to the backup:
ubuntu@dest$ rsync -azP -e ssh [email protected]:/home/ubuntu/sampledir/ backup
As this is the first time, all files from sampledir on the remote server will be downloaded in a backup directory on your local system...