Project 2: backup script
In your second project you need to develop a backup shell script that allows a user to backup selected directories. This project will contain two parts.
Part 1 – the script itself
In the first part of the project, you should write the script itself. The backup script should do the following:
- it takes two arguments: the name of the directory to which you need to save backup file and a name of the file with the list of directories that the script needs to backup.
- the script should check
- the number of arguments and print the usage message if not all arguments are provided
- that the backup directory is in fact a directory
- that argument file is a readable file
- if all needed arguments are given, the script should
- within the specified backup folder create a sub-folder named backup_today's date. For example, if the script is run on March 14, 2008, the sub-directory name should be backup_2008-03-14
- read the contents of the argument file and compress each given directory into its own file. Please use the tar command for the compression. If the name of the directory to backup is for example /home/daniel the created file should have a name home-daniel.tar.gz. Hint: use the tr command to transform the slash symbols '/' into dashes '-'.
- This file should be created in the new backup directory the script just created.
Part 2 – running the backup script
In the second part of the script you need to read pages 532-539 and answer the following questions:
- How would you run this script at exactly 2am every Sunday using the at command?
- How would you run this script at exactly 2am every day using the at command?
- How would you run this script at exactly 2am today using the at command?
- How would you run this script at exactly 2am on March 31, 2008 using the at command?
- How would you view the list of the tasks scheduled by the at command?
- Explain what would be the cron file that would run the same script at the same times. In other words, how would you perform the same scheduling tasks using the cron service?