CT320: Network and System Administration

Fall 2018

HW 3

CT320 HW3: backup script                

made at imgflip.com

Individual Work                

Bash Shell Script                

The purpose of this assignment is to write a bash script called backup that is both practical and uses many features of bash. Your script may incidentally use other programs such as grep, but it must be, primarily, a bash script.                 

Description                

This assignment consists of writing a backup and restore program for user data on a Linux system. This assignment will be graded on how you meet the requirements in this document, so read all parts of the assignment carefully. We have listed the requirements and a list of steps to follow.                 

Debugging                

If you encounter “STACK FRAME LINK OVERFLOW”, then try this:

    export STACK_FRAME_LINK_OVERRIDE=ffff-ad921d60486366258809553a3db49a4a

Requirements                

The manager of system administration at your company is evaluating backup solutions from different companies, and has not yet found one that meets all the requirements. In the meantime he wants an interim solution for backing up user data on the Linux workstations in the engineering lab. Each workstation can have one or more user, each of whom often uses the workstation every day and has large amounts of data. The manager asks you to develop a bash script that will backup data on all workstations nightly. The same script must be capable of allowing you to restore data from the backup in case recovery is needed because files were accidentally deleted.                 

Steps                

Develop a bash script called backup that takes three command-line arguments. The first argument is an action, which is either -S for save or -R for restore. The second is the directory where user accounts reside, which would normally be /home. The third argument is the directory where the backup files will reside, for example /tmp/archive.                 

The -S action causes the script to:                 

The script must also create a file in the backup directory called backups-here that contains backup status:                 

When the -R action is requested, the script will:                 

Here is an example of the format of backups-here:                 

    smith,/home/smith,1475112654,100,10,14598723
    jones,/home/jones,1475061234,6,1,192845

Testing                

To verify your script, you must do the following:                 

  1. Create a directory in your home directory called ~/fakehome, and create user directories in it called alpha, beta, gamma, delta, and epsilon.
  2. Populate the user directories. At least one user should have at least two levels of directory hierarchy, and every user should have multiple files.
  3. Put files in the hierarchy that have different content, size, and protection, for example you could include audio, video, photo, and text files.
  4. Use the find command to enumerate all of the files in ~/fakehome with a full listing including size, date, and protections, and store it in baseline.txt.
  5. Run the script as ./backup -S ~/fakehome /tmp/archive. Ensure that the tar files are created correctly in /tmp/archive, and check the backups-here file.
  6. Delete several random files from different user directories at different levels in the hierarchy to simulate files being accidentally lost.
  7. Run the script as ./backup -R ~/fakehome /tmp/archive to restore any missing files for all users.
  8. Repeat the find command to enumerate all of the files in ~/fakehome with a full listing including size, date, and protections, and store it in restored.txt.
  9. Verify that baseline.txt and restored.txt have identical contents, thereby showing that the restore worked correctly.

More Requirements                

Hints                

No logging is required for the assignment. It’s ok if your script displays a few extra messages, but don’t display an extra message for every file or directory—that’s too much.                 

How to submit your homework:                

Via web checkin, or:                 

    ~ct320/bin/checkin HW3 backup

How to receive negative points:                

Turn in someone else’s work.                 

User: Guest                 

Check: HTML CSS
Edit History Source

Modified: 2018-10-04T20:50                 

Apply to CSU | Contact CSU | Disclaimer | Equal Opportunity
Colorado State University, Fort Collins, CO 80523 USA
© 2018 Colorado State University
CS Building