Synchronizing files with Rsync

In this recipe, we will learn how to use the Rsync utility to synchronize files between two directories or between two servers.

How to do it…

Follow these steps to synchronize files with Rsync:

  1. Set up key-based authentication between source and destination servers. We can use password authentication as well, which is described later in this recipe.
  2. 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}
    
  3. 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 ...

Get Ubuntu Server Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.