- Lab
- A Cloud Guru
Backup and Recovery Using Rsync
This hands-on lab is designed specifically to show how a free tool, `rsync`, can be used to perform backup and recovery operations from a local system to a remote one. Rsync derives its name from its main task: remote synchronization. It is commonly used as a backup or mirroring tool, but can also be used to sync files either remotely or locally. To view the man page for rsync, click [here](https://linux.die.net/man/1/rsync).
Path Info
Table of Contents
-
Challenge
Install Rsync
Install Rsync on both
Server1
andClient1
:yum install rsync
Note: To use the above command without adding
sudo
, you will need to be theroot
user. If you do not elevate privileges toroot
, you will need to addsudo
to the beginning of the command. Either way is fine. -
Challenge
Create a Directory for Backup on Client1
Create a new directory called
files4backup
:mkdir /home/cloud_user/files4backup
-
Challenge
Create Two Files in files4backup, tps_report1.txt and tps_report2.txt, Which Will Be Used to Verify That the Backup Was Successful Later On
Create two new text files,
tps_report1.txt
andtps_report2.txt
:touch /home/cloud_user/files4backup/tps_report1.txt touch /home/cloud_user/files4backup/tps_report2.txt
-
Challenge
Using rsync, Copy the Files from Client1 to Server1
Run the following command:
rsync -avz /home/cloud_user/files4backup/ [email protected]:/home/cloud_user/files4backup/
You may be prompted for a password. If so, use the one provided on the lab page for
cloud_user
Verify that the contents of the
files4backup
directory were copied fromClient1
toServer1
. This can be accomplished by logging intoServer1
and running the following commands:cd /home/cloud_user/files4backup ls
The two files that we created in in the last step should be present.
-
Challenge
OPTIONAL - Modify tps_report1.txt and Verify That the Changes Are Carried over after Performing Another Copy to Server1
On
Client1
:Open the
tps_report1.txt
file:vim /home/cloud_user/files4backup/tps_report1.txt
Add some text to the file and save it, then perform another remote copy:
rsync -avz /home/cloud_user/files4backup/ [email protected]:/home/cloud_user/files4backup/
Back on
Server1
:Open the
tps_report1.txt
file to verify that the changes were carried over:vim tps_report1.txt
-
Challenge
Delete a File in the files4backup Directory on Client1 and Restore It from Server1
On
Client1
, removetps_report2.txt
:rm /home/cloud_user/files4backup/tps_report2.txt
Verify that it's gone:
cd /home/cloud_user/files4backup/ ls
We should only see
tps_report1.txt
in there.From
Server1
, run a remote copy of ourfiles4backup
directory back toClient1
:rsync -avz /home/cloud_user/files4backup/ [email protected]:/home/cloud_user/files4backup/
Back on
Client1
, verify thattps_report2.txt
exists:cd /home/cloud_user/files4backup ls
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.