UNIX Machine Backups

Backups Using Windows

Media at the AOC

Backups to DVD/CDRs

Snapshots

 

Backups Using UNIX Machines

 

Why Backup

The hard disks on your desks can fail, and you should be making regular backups to protect your data.  This page tells you what to watch out for, and how to back up your disk(s).  If you have multiple disks on your system, be very careful that critical data is being stored where you think it is, especially if you are only making backups of some of them (not a good idea). Sometimes this can be confusing.

Don't wait for the warning signs before making a backup; most of the time there won't be any.

Please do not ignore error messages from devices like "sda", "hda", etc.  These are your disks.  A reboot may look like it clears them up, but they're a sign that the disk is having problems, and sooner or later it will not come back.  If you see errors related to these, and you do not have a recent backup, you should immediately start one, and notify the Help Desk about the errors.  Unusual noises are also a bad sign, possibly that the bearings are failing, and a blocked or broken fan can cause the disk to overheat and fail.  Proper ventilation is vital for the hardware to function reliably, so please do not block either the intake holes or the exhaust (the latter is usually at the back; the former may be almost anywhere).  Never move the computer equipment on your desk yourself; always contact the Help Desk if you need things rearranged.  It is very easy to damage cables and equipment, or to connect it incorrectly.

What to Backup

Most desktop computers at the AOC have at least two extra hard drives.  These drives are often SCSI drives for performance reasons and are there strictly for the purpose of data manipulation space. The disks are usually accessed by /home/<hostname> and /home/<hostname>2.  It is left up to the user of each machine to backup the data on these disks if they wish.  If you don't use either of these disks then you don't have to worry about backing anything up.

How To Backup

The most common commands for tape manipulation on a UNIX machine are tar and mt.

You should always use a "relative" (relative to your current working directory) pathname for backup of a directory, such as ".", since one of the quirks of tar is that files with explicit pathnames on a tape can only be restored to the same place.  For example, if you were to take the tape somewhere else, you could only restore the contents if you had a directory available with exactly the same full pathname as the original.  By using the ".", you can later restore the files into whatever directory you are working in then.  Tar will maintain the tree of subdirectories if there are any.

Be careful if you already have files on the tape, since UNIX will start writing wherever the tape is positioned.  It is possible to append to a tape, thus saving the data already on it, but in practice it is much easier to use one tape per save.  If you really want to write multiple saves to a tape, have a look at  man mt, specifically the fsf option.

Backup Using Linux

Most of the UNIX machines at the AOC run Linux these days, so that will be the primary example.  Most of the Linux machines in the Workstation Areas have DDS-4 and Exabyte drives.  The DDS-4 drives use 4mm tape with an uncompressed capacity of 20GB and are usually device /dev/nst1.  The Exabyte drives use an 8mm tape with an uncompressed capacity of 5GB and are usually device /dev/nst0. Each tape device should have a label on the front telling its type and device.  You may want to double check this.

The name of the computer on my desk is rastan.  So, for example, if I wanted to backup the first SCSI disk on my machine, I would login to a Linux machine in the Workstation Area - say alfirk and type the following...

alfirk% cd /home/rastan < - change to the directory you want to backup
alfirk% mt -f /dev/nst1 rewind < - rewind tape
alfirk% tar -cvf /dev/nst1 . < - write files to tape using no-auto-rewind device name
alfirk% mt -f /dev/nst1 rewind < - rewind tape
alfirk% tar -tvf /dev/nst1 < - read back the table of contents from the tape (optional)

Note that you could redirect the output of the table of contents listing into a file, or pipe it into a printing command or a screen-pager program like less.  That way you could make it easier to read through, or save it permanently.

alfirk% tar -tvf /dev/nst1 > ~/tape.list

Look in man tar for even better examples.

Backup Using Solaris

The SPARC/Solaris machine in Workstation Area 1 (tesuque) has a DDS-3 and Exabyte drive. The DDS-3 drive uses 4mm tape with an uncompressed capacity of 12GB and is device /dev/rmt/1ln.  The Exabyte drives use an 8mm tape with an uncompressed capacity of 5GB and is device /dev/rmt/0ln.

The name of the computer on my desk is rastan.  So, for example, if I wanted to backup the first SCSI disk on my machine, I would login to a Solaris machine in the Workstation Area - say tesuque and type the following...

tesuque% cd /home/rastan < - change to directory you want to backup
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape
tesuque% tar -cvf /dev/rmt/1ln . < - write files to tape using no-auto-rewind device name
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape
tesuque% tar -tvf /dev/rmt/1ln < - read back the table of contents from the tape (optional)

Note that you could redirect the output of the table of contents listing into a file, or pipe it into a printing command or a screen-pager program like less. That way you could make it easier to read through, or save it permanently.

tesuque% tar -tvf /dev/rmt/1ln > ~/tape.list

Look in man tar for even better examples.

How to Restore

The most common commands for tape manipulation on a UNIX machine are tar and mt.

Make sure you have enough disk space to restore the files from tape.  If the tape is a DDS-4, for example, it may have upwards of 20GB of data on it.  If you want to restore all of it, you will need 20GB of free space someplace.  Also, be careful of where you restore files.  Restoring files will overwrite existing files of the same name.

Restore Using Linux

Most of the UNIX machines at the AOC run Linux these days, so that will be the primary example.  Most of the Linux machines in the Workstation Areas have DDS-4 and Exabyte drives.  The DDS-4 drives use 4mm tape with an uncompressed capacity of 20GB and are usually device /dev/nst1.  The Exabyte drives use an 8mm tape with an uncompressed capacity of 5GB and are usually device /dev/nst0.  Each tape device should have a label on the front telling its type and device.  You may want to double check this.

In the How to Backup example I saved all the data from /home/rastan to a DDS-4 tape.  Now I want to restore that data /home/megrez.  Again, I will login to the machine alfirk because it has a DDS-4 tape drive.

alfirk% cd /home/megrez < - change to the directory you want the restore to go
alfirk% mt -f /dev/nst1 rewind < - rewind tape
alfirk% tar -xvf /dev/nst1 . < - write files from tape using no-auto-rewind device name
alfirk% mt -f /dev/nst1 rewind < - rewind tape

If you want to restore specific files from the tape instead of the entire tape, you can do that as well.  This example will restore only the files in the krowe/files/important directory from the tape.  A list, or table of contents, of the tape can be viewed by typing tar -tvf /dev/nst1

alfirk% cd /home/megrez < - change to the directory you want the restore to go
alfirk% mt -f /dev/nst1 rewind < - rewind tape
alfirk% tar -xvf /dev/nst1 ./krowe/files/important < - write files from tape using no-auto-rewind device name
alfirk% mt -f /dev/nst1 rewind < - rewind tape

Restore Using Solaris

The SPARC/Solaris machine in Workstation Area 1 (tesuque) has a DDS-3 and Exabyte drive.  The DDS-3 drive use 4mm tape with an uncompressed capacity of 12GB and is device /dev/rmt/1ln.  The Exabyte drive uses an 8mm tape with an uncompressed capacity of 5GB and is device /dev/rmt/0ln.

In the How to Backup example I saved all the data from /home/rastan to a DDS-3 tape.  Now I want to restore that data /home/megrez.  Again, I will login to the machine alfirk because it has a DDS-4 tape drive which can read DDS-3 tapes.

tesuque% cd /home/megrez < - change to the directory you want the restore to go
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape
tesuque% tar -xvf /dev/rmt/1ln . < - write files from tape using no-auto-rewind device name
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape

If you want to restore specific files from the tape instead of the entire tape, you can do that as well.  This example will restore only the files in the krowe/files/important directory from the tape.  A list, or table of contents, of the tape can be viewed by typing tar -tvf /dev/rmt/1ln

tesuque% cd /home/megrez < - change to the directory you want the restore to go
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape
tesuque% tar -xvf /dev/rmt/1ln ./krowe/files/important < - write files from tape using no-auto-rewind device name
tesuque% mt -f /dev/rmt/1ln rewind < - rewind tape

Content reviewed on: 28-Jun-2007
Reviewed by: krowe