The FreeBSD Diary |
(TM) | Providing practical examples since 1998If you buy from Amazon USA, please support us by using this link. |
How to restore from a tape backup if your hard drive dies
29 March 2000
|
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:
|
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:
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.
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.
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 The value for the "specify next volume #: " is 1 since each file system is dumped with an option "a". Troy writes:
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 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:
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:
My thanks to Troy for this article. |
Harald Neuffer wrote in with this information:
back to the restore. |