Homework 13: Backup
Due Monday, May 7, at 10:30 (start of the final exam)
For this homework, create a backup program and a restore program. The program will archive all the files in your home directory, or a different directory if the user specifies it. Use tar to archive files.
The program should support these options:
Change the file extension depending on what options have been selected. For a standard tar archive, the extension is .tar. Additional options may add more extensions. Possibilities for extension are:
- -z specifies that the tar archive should be compressed with gzip
- -j specifies that the tar archive should be compressed with bzip2
- -e specifies that the tar archive should be encrypted. You can use aespipe to encrypt archives.
- -r specifies that the tar archive should include directories. Otherwise, don't include directories, just regular files. The "zip" command has similar behavior, as do many others.
- -d specifies the directory to archive (default to the user's home directory if not specified. Don't put your home directory in the program, but rather use the value of $HOME).
-z and -j cannot both be specified. Your program can either refuse to create a backup, or compress with -j if both are specified, but should NOT compress with both methods (do not create backup.tar.gz.bz2.aes).
The program operates like this:
- Make a tar archive of the files in your home directory (recursive if specified).
- Use gzip or bzip2 if requested by command line options (this can be combined with step 1 using tar options if you like.
- Encrypt the file, if specified by the command line option
The restore program
The unpack program should not take any parameters except for the name of the backup to unpack. It should use the file extensions to determine what needs to be done (decompress or decrypt). If you need to decrypt the file, do that first, then decompress and unarchive.
The user should not be prompted for any input except by aespipe (which asks for a password). Do not use the input statement in your program.
Turning in the assignment
Breaking tradition with past assignments, name your backup program "backup", and your restore program "restore". Grading will be as follows (50 points total this assignment)
- 5 points for correct name
- 5 points for correct permissions (700)
- 5 points if archiving works correctly without options
- 5 points for the -r option
- 5 points for the -z and -j options
- 5 points for the -e option
- 5 points for the -d option
- 15 points for the restore program