Skip to main content

Backup and Recovery

Hands-On Lab

 

Photo of

Training Architect

Length

01:00:00

Difficulty

Beginner

In this hands-on lab, we will create a backup of a folder that exists on Server1 to our backup location, Client1. We will do this with the open-source tool rsync.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Backup and Recovery

Introduction

In this hands-on lab, we will create a backup of a folder that exists on Server1 to our backup location, Client1. We will do this with the open-source tool rsync.

Connecting to the Lab

Log In to Server1

  1. Open your terminal application, and run the following command (remember to replace <SERVER1_PUBLIC_IP> with the Server1 public IP you were provided on the lab instructions page):
    ssh cloud_user@<SERVER1_PUBLIC_IP>
  2. Type yes at the prompt.
  3. Enter your cloud_user password at the prompt.
  4. Become the root user.
    sudo su -

Log In to Client1

  1. In a new terminal window, run the following command (remember to replace <CLIENT1_PUBLIC_IP> with the Client1 public IP you were provided on the lab instructions page):
    ssh cloud_user@<CLIENT1_PUBLIC_IP>
  2. Type yes at the prompt.
  3. Enter your cloud_user password at the prompt.
  4. Become the root user.
    sudo su -

Install rsync

  1. In your Server1 terminal window, run the following command:
    yum install rsync
  2. Type y at the prompt.
  3. Repeat these steps in your Client1 terminal window.

Create a Backup Directory

  1. Switch to your Server1 terminal window, and create a new directory called files4backup.
    mkdir /home/cloud_user/files4backup

Add Two Test Files to the Backup Directory

  1. Create a new text file called backup1.txt.
    cat > /home/cloud_user/files4backup/backup1.txt
  2. At the prompt, enter some text.
  3. Press Ctrl + Z.
  4. Create a second new text file called backup2.txt.
    cat > /home/cloud_user/files4backup/backup2.txt
  5. At the prompt, enter some text.
  6. Press Ctrl + Z.
  7. Change to the files4backup directory.
    cd /home/cloud_user/files4backup
  8. Verify that the text files were successfully created.
    ls -l

Copy the Backup Directory from Server1 to Client1

  1. Run the following command:
    rsync -avz /home/cloud_user/files4backup/ cloud_user@10.0.1.11:/home/cloud_user/files4backup/
  2. Type yes at the prompt.
  3. Enter your cloud_user password at the prompt.
  4. Switch to your Client1 terminal window.
  5. Change to the directory /home/cloud_user.
    cd /home/cloud_user/
  6. List the contents of the directory.
    ls
  7. Change to the files4backup directory.
    cd files4backup/
  8. List the contents of the directory.
    ls

Edit backup1.txt and Verify that the Changes Were Carried Over

  1. Switch to your Server1 terminal window.
  2. Open the backup1.txt file.
    vim backup1.txt
  3. Add some text to the file.
  4. Press Esc, then type :wq to save and exit the vim text editor.
  5. Perform a remote copy again.
    rsync -avz /home/cloud_user/files4backup/ cloud_user@10.0.1.11:/home/cloud_user/files4backup/
  6. Enter your password at the prompt.
  7. Switch to your Client1 terminal window.
  8. List the contents of the current directory.
    ls
  9. Open the backup1.txt file to verify that the changes were carried over.
    vim backup1.txt

Conclusion

Congratulations, you've successfully completed this hands-on lab!