0% found this document useful (0 votes)
3 views

Lab 2 Automatic backups

Uploaded by

Jay D
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 2 Automatic backups

Uploaded by

Jay D
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Program: CS

Course: Unix Security


Lab 2: Automatic backups

Name: ___________________________________

Import the VM provided in Debian-Server.ova into Virtual Box. Then, respond to all questions
in your own words, providing screenshots of your work to support it.

NOTE: If you are using a previously imported VM, it is recommendable to create a snapshot before
making any modifications requested in this lab. After finishing, you can restore the snapshot to get
to the original state.

Part A: Using dd

The tool dd can be used to backup data on the entire partition without reading the file system,
which would also be backed up. The resulting backup can be sent to a regular file somewhere else
or to a device file belonging to the destination partition, so synchronizing two partitions with the
same data. In any case, the data is read block by block, which is fast but does not take into
consideration file system information, such as modification times.

Tutorial: https://www.makeuseof.com/tag/easily-clone-restore-linux-disk-image-dd/

1. As root, check the mounted file systems with “df -h” and the available partitions in the 2nd
disk with “fdisk -l /dev/sdb”. Do you think you can create an image of the partition
storing /home into a file under /mnt/data? Why or why not?

2. You are going to clone the partition /dev/sdb1 into /dev/sdb2, that is, an exact copy.
First, free the destination by executing “umount /dev/sdb2”. Then, execute the cloning
command, “dd if=/dev/sdb1 of=/dev/sdb2 bs=1M”. Finally, create the mount point
/mnt/copy and mount it again with “mount /dev/sdb2 /mnt/copy”. Both should be
identical as per the output of “ls /mnt/data /mnt/copy”. Show all operations.

3. Why only 1024 records in and out were performed? Does the process is affected by how
much data the partition contains? Explain your answer.

4. Now create an image of /dev/sdb1 in a file in /mnt/copy. Show the command you used
and long list the resulting file.
Program: CS
Course: Unix Security
Lab 2: Automatic backups

5. Why the command did not successfully completed? What should you do?

6. Create a new file system in the 3rd partition of the 2nd disk using the tool mkfs.ext4 and
mount it in /mnt/backups, which must be created first. Show all commands, including
“df -h /mnt/backups”.

7. Try again backing /dev/sdb1 up, but this time store the image in
/mnt/backups/sdb1.img. Compare the output with the first try.

8. Pretending there was a mistake by someone, remove the whole directory projects in
/mnt/data. Then, restore the backup using dd. Show all the process, including the content
of /mnt/data after the restoration.

Part B: Using rsync


rsync is a powerful tool used to synchronize directories locally or remotely, providing coverage for
full or incremental backups.
Tutorial: https://phoenixnap.com/kb/rsync-back-up-data
9. Considering you have a 18 GB partition mounted in /mnt/backups, execute the command
“rsync -av /etc /mnt/backups” to safeguard the system configuration. Show the
summary after the synchronization.

10. Add a new user with adduser. Then synchronize again. Show the process and explain if it
was a full or incremental backup.

11. Write down the command to backup the system configuration to a remote system with IP
192.168.0.15, in the folder /backups/debian-server, considering that the
communication would use SSH and the user to connect to would be remotebackups.
Program: CS
Course: Unix Security
Lab 2: Automatic backups

Part C: Automating backups


Tutorial: https://linuxhandbook.com/crontab/
12. Create a shell script in /root that backs /home up to /mnt/backups using rsync in
verbose mode. The script’s name should be backup.sh and have execution permission.
Consider the 1st line all scripts should begin with. Show its content.

13. How do you execute it? Do it twice and show the output of the last execution. Why the file
list is empty?

14. Create a new crontab entry to perform scheduled backups with your shell script every
Sunday at 2:30 AM (the night between Saturday and Sunday). Please note the output would
be sent by email to root. Show the entry with “crontab -l”.

You might also like