Learning how to use rsync
In our previous recipe, we worked with SSH from the client standpoint. We used SSH and SCP
to both log in and copy files from source to destination. We discussed how to use a username/password combination to log in to a remote system, as well as how to use SSH key-based authentication. If we focus on SCP for a second, there's one thing that we didn't discuss, and that is how to synchronize the local source to the local destination, or, even better, how to create a scenario in which we synchronize the local source to a remote destination and vice versa between two Linux servers in place. This is where it's best to use rsync
, a tool that's meant to do just that. Let's get cracking.
Getting ready
We will continue using our cli1
and cli2
machines, running Ubuntu and CentOS. Let's get ready by making sure that the necessary packages are installed. We need to use this command for Ubuntu:
apt -y install rsync
We use the following...