Backing up and Restoring Files on Wocket by Hand


What data do we routinely back up?

It is generally a good idea to make backups of the following directories daily, because their contents change on a daily basis:

It is also a good idea to make backups of these additional directories on a more infrequent basis (in particular, when you have reason to believe that their files have been altered significantly): Note that we do not back up the Solaris 6 OS itself. If for some reason the entire machine is wiped, it is easiest to reinstall a fresh copy of the OS off of CD and then quickly reconfigure it by then extracting the saved data from the above backups.

Where and how are the files backed up?

The files are backed up as tar (tape archive) files on 4mm magnetic tape using the tape drive attached to wocket in room 448 C&SRL. The files for each directory are tarred and preserved as a single file on the tape. As there will be multiple files on the tape, you will need to provide a table of contents (also by hand) for the tape so that the files may easily extracted in the future.

Exactly how do I create the backup files?

  1. Make sure you are actually logged into wocket. You can log into wocket either at the console or by ssh from a window on another machine (namely staff.uiuc.edu or eesn2.ews.uiuc.edu).

  2. Make sure you are root. You need to be root because root has both permissions to read and write from the tape drive device and also to read every single one of the files that is to be backed up.

    You become root by typing su - root and then supplying the root password when asked.

  3. Put the current tape into the 4mm tape drive on wocket.
    Notice that the tapes have an arrow indicating the correct direction to insert them. The tape will go in slightly, then there will be a slight bit of resistance and the drive should take the tape in by itself - much like a VCR.

  4. Type mt rewind to be sure that the tape is rewound to the very beginning.

  5. Type mt status to check the status of the tape. You should see something like the following:
    Archive Python 4mm Helical Scan tape drive:
    sense key(0x0)= No Additional Sense   residual= 0   retries= 0
    file no= 0   block no= 0
          
    The file no= 0 means you are positioned at file 0. You may type mt status at any time to check the position of the tape.

  6. If there are already previous backups on the tape that you need to keep (ones made the previous day, for example), you will need to advance the tape past these files so that your new backup will appear after them. To advance the tape, type mt fsf X, where X is the number of files you need to advance by. If you are at file 5, and want to write in position 8, you would type mt fsf 3. Similarly, to rewind the tape by X files, type mt bsf X. Always type mt status to be sure the tape is positioned at the end of the files you wish to save (alternatively, at the beginning of the nonexistent file you will be writing) before proceeding.

    Always remember that the first file on the tape is file 0. For example, if you have 4 backup files on the tape already and today's file will be the 5th, you will need to advance the tape to file 4 (not 5!) with the command mt fsf 4 after rewinding it.

    Note that after creating a backup file, you are right in position to create the next backup file with no further rewinding or forwarding.

  7. Change directories into the directory for which you wish to create a backup. As described at the beginning of this file, these will be /usr/local/webdata and /export/home.

    Doing the backups from these directories means that all of the files will be saved relative to the directories. This allows us to later extract copies of these files in some other location (/tmp, for example) without overwriting any existing files.

  8. To create a tape archive of all of the files in the directory that you are in, type tar -cvf /dev/rmt/0n *.

    The options to tar (-cvf) stand for:

    • c: Create. This one you need.
    • v: Verbose. This is optional, it makes the command list each file as it adds it to the archive. It can slow things down, but it's useful for large directories - without it it is hard to tell how far you've gotten, or if the process has just hung.
    • f: File. This means you'll specify the name of the tar file to create. The filename we use is /dev/rmt/0n. This means "the first tape device, non-rewinding." The n is important - it means that the tape will not automatically rewind to the beginning when the file is created. This leaves you in position to create the next archive file right away.

    The argument * to tar means "include all the files in this directory in the archive." If you wanted to include only some files in the archive, you would list them here instead.

    Now you have all the files in the directory archived onto the tape. You are ready to create the next tape archive. Change into that directory, and repeat the tar command there. Notice that the tar command is the same for all the directories. All it says is "make an archive of every file in this directory."

  9. If the file creation fails with an I/O error, you've run out of space on the tape. Should this happen, simply eject the tape (see below) and begin anew with a fresh tape.

  10. Should you wish to review the contents of the archives you've made (this isn't strictly necessary, particularly if you've used the v option to tar above and therefore saw the files go in), you may position the tape at the beginning of the appropriate archive file by using the mt fsf and mt bsf commands described earlier, and then type tar -tf /dev/rmt/0n.

    The options to tar (-tf) stand for:

    • t: Table of contents.
    • f: File. This means you'll specify a tar file to list the contents of. The filename was explained in the creation step above.

  11. Make a table of contents for the tape. You will need to do this by hand. Simply cut out a piece of paper to serve as a tape cover, and write on it
    • the file number (remember, numbering starts with 0!)
    • the file contents (the directory backed up)
    • the date
    for each archive file you've created.

  12. Take the tape out of the tape drive when you are finished. To do this, type mt rewoff. This will rewind the tape before ejecting it.

How do I restore backed up files from the tape?

  1. Make sure you are actually logged into wocket. You can log into wocket either at the console or by ssh from a window on another machine (namely staff.uiuc.edu or eesn2.ews.uiuc.edu).

  2. Make sure you are root. You need to be root because root has both permissions to read and write from the tape drive device and also to write every single one of the files that is to be restored.

    You become root by typing su - root and then supplying the root password when asked.

  3. Put the current tape into the 4mm tape drive on wocket.
    Notice that the tapes have an arrow indicating the correct direction to insert them. The tape will go in slightly, then there will be a slight bit of resistance and the drive should take the tape in by itself - much like a VCR.

  4. Change directories into some temporary directory on your machine with a lot of space available. Generally this will be one of either /tmp or /scratch. To view the amount of space available in the directory, type df -k.

    We restore the files into a temporary directory first rather than directly into their desired location as a safety measure - if you make a mistake and restore too many files (old versions of files, backed up a few days back, after all!) you will not accidentally overwrite newer versions of those files.

  5. Type mt rewind to be sure that the tape is rewound to the very beginning.

  6. Type mt status to check the status of the tape. You should see something like the following:
    Archive Python 4mm Helical Scan tape drive:
    sense key(0x0)= No Additional Sense   residual= 0   retries= 0
    file no= 0   block no= 0
          
    The file no= 0 means you are positioned at file 0. You may type mt status at any time to check the position of the tape.

  7. If you need a file other than the one at which the tape is currently positioned, you will need to advance or rewind the tape. To advance the tape, type mt fsf X, where X is the number of files you need to advance by. If you are at file 5, and need file 8, you would type mt fsf 3. Similarly, to rewind the tape by X files, type mt bsf X. Always type mt status to be sure the tape is positioned at the file you need before proceeding.

  8. To list all of the files in the tar file on tape that you're positioned at (just to check what's in there, if you feel the need) type tar -tf /dev/rmt/0n.

    The options to tar (-tf) stand for:

    • t: Table of contents.
    • f: File. This means you'll specify a tar file to list the contents of. The filename is explained below.

  9. To extract all of the files in the tar file on tape that you're positioned at into your current working directory (the big beefy directory mentioned above), type tar -xvf /dev/rmt/0n.

    The options to tar (-xvf) stand for:

    • x: Extract. This one you need.
    • v: Verbose. This is optional, it makes the command list each file as it extracts it. It can slow things down, but it's useful for large files - without it it is hard to tell how far you've gotten, or if the process has just hung.
    • f: File. This means you'll specify a tar file to extract from. The filename we use is /dev/rmt/0n. This means "the first tape device, non-rewinding." Your system may have a slightly different name for it, check if this command gives you any trouble. The n is important - it means that the tape will not automatically rewind to the beginning when the files are extracted.

    Alternatively, to extract only some of the files on the tape into the temporary directory (the one you've deleted by accident and are trying to restore, for instance), simply list the filenames after the tar command. For example:

          tar -xvf /dev/rmt/0n mallard/beta/docs/cgi-bin/homepage.cgi
          
    will restore the homepage.cgi program on the beta port, assuming you are extracting from an archive file of the /usr/local/webdata directory. Notice that because that tape archive was created in the /usr/local/webdata directory (as described in the instructions on creating the files, above), the files you wish to restore must be specified relative to that directory, not given with absolute pathnames.

    Now you have all the files you restored sitting in the temporary directory.

  10. Copy the files into their appropriate locations. Alternatively, you may wish to leave them in the temporary directory and alert their owner to come and get them.

  11. Take the tape out of the tape drive when you are finished. To do this, type mt rewoff. This will rewind the tape before ejecting it.

Questions? Comments? General harrassment? Mail it to maiko@wocket.csl.uiuc.edu.