Task A – Backup your system (Using crontab) [100 points]
Scenario: Performing system backup can be time-consuming, and the process is often
overlooked. For this scenario:
1. (10 Points) Create a new user Alice (with home directory).
2. (50 Points) Write a shell script that backups Alice’s home directory by creating a
tar file (tape archive), using the following steps:
a. Do the following:
• Take 2 inputs with their values- your MIDAS name and current date
(for example, midas=Mohammed).
• Create a variable named as filename that should be assigned the
value as MIDAS-date (example output after executing the script
would be like, Mohammed-2024.11.04-22.08.01.tar.gz).
• Using tar command, create a tape archive for Alice’s home directory
(/home/Alice) and the filename created above (in step-2-ii). (Please
learn about tar command in Linux for its usage)
b. Move the tape archive file/tar file (created in step 2-iii) to /var/backups/
directory using correct command in linux.
c. To optimize the disk usage, pick a compression algorithm (bz2, gzip, or xv) to
compress the tar file you created in /var/backups/ in the previous step-2b.
3. (30 Points) Create a crontab file to keep the scheduled task running for 3
minutes, then check the contents in the /var/backups directory.
4. (10 Points) Cancel the crontab jobs.
Reflection
This lab gave me experience with automating system backups using a shell script and scheduling task with crontab. A challenge I faced was setting up the cron job to automate the backup, but testing it and ensuring the scheduled task ran correctly helped reinforce my understanding of cron syntax.