The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]
How to restore from a tape backup if your hard drive dies 29 March 2000
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles
Troy P. Bahan wrote in with this great little article, which I'm sure some of you will need sooner or later.  I know I'm going to need it one day.  Let's face it: hard disks fail.  Better to be prepared than sorry.
The equipment
Troy has the following installed on his custom built PC:

Quantum DLT tape dirve.
Adaptec 2940U2W SCSI card.
IBM ULTRASTAR WIDE ULTRA2 SCSI Hard Drive.

The backup
Troy is using dump to backup his system.  See torture-testing Backup and Archive Programs (http://reality.sgi.com/zwicky_neu/testdump.doc.html) which compares the various software tools for backing up a disk   dump came out on top because of it's ability to work under a wide variety of conditions and still precisely preserve the disk image.

The following is a simple shell script which is called from crontab.   This file is also available as samples/dump.sh.txt and is more suitable for downloading.

#!/bin/sh
  TARGET=/dev/nrsa0
  FILESYSTEMS=/:/var:/usr
  DUMPLEVEL=0
  DUMPOPTIONS=au
  MTACTION=rewind
 
  MT=/usr/bin/mt
  SED=/usr/bin/sed
  DUMP=/sbin/dump
 
#Rewind the tape
  echo "${MT} ${MTACTION}"
  ${MT} ${MTACTION}
#Do the dump for each file system
  for i in `echo $FILESYSTEMS | ${SED} 's/:/ /g'`
  do
          echo "${DUMP} ${DUMPLEVEL}${DUMPOPTIONS}f ${TARGET} $i"
          ${DUMP} ${DUMPLEVEL}${DUMPOPTIONS}f ${TARGET} $i
  done
#Rewind the tape
  echo "${MT} ${MTACTION}"
  ${MT} ${MTACTION}
The assumptions
We make the following assumptions in this article:
  • the hard drive is dead.
  • all the file systems has been backed up on a tape using "dump".
    [In my case /, /var and /usr has bee backed up to Quantum DLTtape tape.]
  • you have have Boot, Root, and Fixit floppies.

Here is the status table for the Troy's tape drive.  This information can be obtained via "mt status".  Please see "man mt" for more information.  This information is used during the restore.

STATUS TABLE
Mode Density Blocksize bpi Compression
Current: 0x19 variable 0 IDRC
---------available modes---------
0: 0x19 variable 0 IDRC
1: 0x19 variable 0 IDRC
2: 0x19 variable 0 IDRC
3: 0x19 variable 0 IDRC
---------------------------------
Current Driver State: at rest.
---------------------------------
File Number: 0 Record Number: 0
    

Note: File Number 0 = / : 1 = /var : 2 = /usr

Read making space first!

This is Troy's check list for restoring an old dump onto a new harddrive.

  1. Install a new Hard Drive to the system.
  2. Boot the system with a Boot and Root floppies.
  3. At the stand/sysinstall Main Menu, choose 5 Configure.
  4. At the FreeBSD Configuration Menu, choose F Fdisk.

Note: If you are booting multi os's from the same disk, next few steps will vary, but we will assume you are using the entire disk for FreeBSD.

  1. At the FDISK partition Editor press A and accept with a YES.
  2. Use the arrow key to hilight da0s1[wd0s1 for non-SCSI drives] in Name column and press S and then Q.
    NOTE : DO NOT PRESS "W" AT THIS TIME. IT WILL CAUSE YOU GRIEF LATER.
  3. Choose (*) Standard at Install Boot Manager.
  4. At the FreeBSD Configuration Menu, choose L Label.
  5. At FreeBSD Disk Lable Editor :
    Create at least /, swap, /var, and /usr.
    Press w and accept with a YES.
  6. Press q and at the Free BSD Configuration Menu, choose E Exit.
  7. At the stand/sysinstall Main Menu, choose F Fixit.
  8. At the Please choose a fixit option, choose 2 Floppy.
  9. Insert Fixit floppy and press enter.
  10. Follow the directions and press Alt-F4 and do the following.

Note: Troy is using a scsi DLT tape drive.  Replace /dev/rsa0 with a appropriate device if an IDE tape drive is used.  If nothing happens in rewind, the tape is at the beginning.

Now we start the Magnetic Tape manipulating program.

mt fsf NUMBER

where NUMBER = File Number of the particular system. See STATUS TABLE above.

The value for the "specify next volume #: " is 1 since each file system is dumped with an option "a".   Troy writes:

Without the "a" option, the "dump" program will automatically calculate and break up the file system in X number of volumes.  Since I already know the size of my DLT tape is larger than the whole hard drive, I can safely tell the "dump" program to write until the end of the tape.  If the hard drive size is larger than the DLT tape size(which is 30GB with compression), then the "a" option maybe dangerous.  Since I do not have any hard drive larger than 30GB yet, I have not tested that part.  I may update it when that time comes.  Thus, the volume number "1" is used. Part of "man dump" says : A dump that is larger than the output medium is broken into multiple volumes.  On most media the size is determined by writing until an end-of-media indication is returned.  This can be enforced by using the -a option.

Fixit# mt rewind 
Fixit# cd /mnt
Fixit# restore rf /dev/rsa0
Note: Ignore all warning messages. 
Fixit# cd /mnt/var
Fixit# mt fsf 1
Fixit# restore rf /dev/rsa0
Fixit# cd /mnt/usr
Fixit# mt fsf 2

Note: One may choose to use restore rf /dev/rsa0 but, it did not restore all /usr so I restored only
/usr/bin, /usr/sbin, /usr/lib, and /usr/libexec. Swap space might be the problem.

Fixit# restore -i
restore > cd bin
restore > add *
restore > cd ../sbin
restore > add *
restore > cd ../lib 
restore > add *
restore > cd ../libexec 
restore > add *
restore > extract
You have not read any tapes yet.
Unless you know which volume your file(s) are on you 
should start with the last volume and work towards 
the first. 
specify next volume #: 1
set owner/mode for '.'? [yn] y

Note: man restore has this to say about set mode:

All the directories that have been added to the ex-
traction list have their owner, modes, and times set;
nothing is extracted from the dump. This is useful
for cleaning up after a restore has been prematurely
aborted.

restore > quit
Fixit# exit

Reboot the system at this time and login in as a root.  Now restore the whole /usr file system.

# cd /usr
# mt fsf 2
# restore -i
To walk around restore, type '?' at the restore > prompt.
restore > ls 
Add everything except bin, sbin, lib, and libexec.
restore > add home
restore > add local
.
.
.
restore > extract
You have not read any tapes yet.
Unless you know which volume your file(s) are on you 
should start with the last volume and work towards the first.
specify next volume #: 1
set owner/mode for '.'? [yn] y
restore > quit
#reboot

The new Hard Drive will be running with the same configuration as before.

Further reading
The following is a list of recommended reading:

man dump
man mt
man restore
FreeBSD handbook : Installing FreeBSD

http://reality.sgi.com/zwicky_neu/testdump.doc.html
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/backups.html

My thanks to Troy for this article.

Harald Neuffer wrote in with this information:

Hi,

read your article about dump and restore. I was searching for a description that allows me to recover a machine without a tape and CD-ROM drive, only using a network interface and the three floppies.

So your description was very close, only the thing that you need an interactive use of restore for /usr partition was not so elegant, but probably you run in the same "file system full" errors like me.

The reason for this is the program restore store temporary informations in /tmp.

A solution is:

Before restoring make the following.

mv /tmp /tmp.old
mkdir /a_place_with_a_lot_of_space
ln -s /a_place_with_a_lot__of_space /tmp

restoring the dump files

rm /tmp
rm -r /a_place_with_a_lot__of_space
mv /tmp.old /tmp

See you,

back to the restore.


Need more help on this topic? Click here
This article has 1 comment
Show me similar articles