How do I restore a tape using just the "tar" command?
From Backup Central
Well, here's the Veritas Support doc for doing this:
But I think this doc might also be helpful:
In case these documents disappear, I'll throw the text in here. Feel free to follow the actual links. They'll be formatted better, and may actually get updated. I only include them here because links like this have a way of disappearing.
Note: This is not a recommended procedure. It should be used only in extreme situations and as a last step in attempting to restore data. This procedure has been used on numerous occasions with success.
First, figure out the fragment number and the block size needed.
# ./bpmedialist -mcontents -ev D0004 media id = D0004, allocated 09/21/99 14:19:, retention level = 1
File number 1 Backup id = jeckle_0937941543 Creation date = 09/21/99 14:19: Expiration date = 10/05/99 14:19: Retention level = 1 Copy number = 1 Fragment number = 1 Block size (in bytes) = 32768
Then work the tape:
ficus# tpreq -ev D0004 -a r -d dlt -p NetBackup -f /tmp/mytape
This issues a tpreq for media id D0004, the " r " is for read, the " -d " is density, " -p " is pool and " -f " is mount point.
ficus# /usr/openv/volmgr/bin/vmoprcmd -d (to verify the media is mounted)
< NONE >
Drv Type Control User Label RVSN EVSN Ready Wr.Enbl. ReqId 0 dlt TLD - No - - 1 dlt TLD root Yes D0004 D0004 Yes Yes 0 2 dlt AVR Yes D0004 Yes Yes -
ADDITIONAL DRIVE STATUS
Drv DriveName Multihost Assigned Comment 0 Drive0 No - 1 Drive1 No ficus 2 Drive2 No - ficus#
ficus# tpconfig -d (to get the device file name for commands):
Index DriveName DrivePath Type Multihost Status ***** ********* ********** **** ********* ****** 0 Drive0 /dev/rmt/0cbn dlt No UP TLD(0) Definition DRIVE=1 1 Drive1 /dev/rmt/1cbn dlt No UP TLD(0) Definition DRIVE=2 2 Drive2 /dev/rmt/1lbn dlt No UP
Currently defined robotics are: TLD(0) robotic path = /dev/sg/c0t6l0, volume database host = ficus
Standalone drive volume database host = saturn
ficus# mt -f /tmp/mytape rew (goes to beginning of tape)
ficus# mt -f /tmp/mytape stat (verify at beginning of tape)
Vendor 'QUANTUM ' Product 'DLT7000 ' tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 0 block no= 0
ficus# mt -f /tmp/mytape fsf (position to file #1)
ficus# mt -f /tmp/mytape stat (verify) Vendor 'QUANTUM ' Product 'DLT7000 ' tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 1 block no= 0
ficus# mt -f /tmp/mytape fsr (position to record 1)
ficus# mt -f /tmp/mytape stat (verify) Vendor 'QUANTUM ' Product 'DLT7000 ' tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 1 block no= 1
ficus# /usr/openv/netbackup/bin/tar -tvf /tmp/mytape (run tar command) Blocksize = 2 records Hmm, this doesn't look like a tar archive. Skipping to next file header...
Since the tar command didn't work in the above scenario, run the stat command to see what file the tape is positioned at:
ficus# mt -f /tmp/mytape stat Vendor 'QUANTUM ' Product 'DLT7000 ' tape drive: sense key(0x0)= No Additional Sense residual= 0 retries= 0 file no= 1 block no= 2
ficus# /usr/openv/netbackup/bin/tar -tvf /tmp/mytape Blocksize = 126 records
Hmm, this doesn't look like a tar archive. Skipping to next file header...
drwxr-xr-x root/other Jul 27 09:51 1999 / drwxr-xr-x root/sys Jul 27 07:36 1999 /etc/ drwxrwxr-x root/sys Mar 8 14:27 1999 /etc/default/ -r--r--r-- root/sys Oct 30 16:58 1996 /etc/default/sys-suspend -r-xr-xr-x bin/bin Mar 5 12:45 1999 /etc/default/cron -r--r--r-- bin/bin Mar 5 12:45 1999 /etc/default/fs -r--r--r-- root/sys Mar 5 12:45 1999 /etc/default/inetinit -r--r--r-- root/sys Mar 5 12:45 1999 /etc/default/kbd -r--r--r-- root/sys Mar 5 12:45 1999 /etc/default/passwd -r--r--r-- root/sys Mar 5 12:45 1999 /etc/default/tar
To get the information off of the tape execute:
/usr/openv/netbackup/bin/tar -xvf /tmp/mytape -b [BYTESIZE/512]
In this example [BYTESIZE/512] is 32768 / 512, which equals 64.
The following will move the data from one host to another host:
Run this at the target host (client). In the below example tape_host is the server with the tape mounted.
rsh tape_host dd if=/tmp/mytape bs=[BLOCKSIZE] \ | /usr/openv/netbackup/bin/tar -xvf - -b [BYTESIZE/512]
In this example [BLOCKSIZE] equals 32768 and [BYTESIZE/512] equals 64.
To unmount the media run /usr/openv/volmgr/bin/tpunmount /tmp/mytape
Netbackup Manual Tar Recovery Jason Consorti 22 December 2000
1. Make sure that Netbackup is installed or the are binaries available from the Netbackup CD. 2. Make sure you have a "media contents" report on the tape. 2.1. A complete Media Contents can come from the tape itself with the bpmedialist command 2.1.1. /usr/openv/netbackup/bin/admincmd/bpmedialist -U \ - mcontents -ev MEDIA_NUMBER 2.2. The real, physical layout of a netbackup tape is as follows 2.2.1. MH * BH Image * BH Image * BH Image * EH * 188.8.131.52. MH is the Media Header 184.108.40.206. * is a tape mark (used for fast forward and rewind) 220.127.116.11. BH is a Backup Header 18.104.22.168. Image is, well, the actual data 22.214.171.124. EH is the Empty Header (used for position validation) 2.3. An Images on Media report is VERY useful. This can only be gotten from the production Netbackup server's data base. It will help you reconstruct full and incremental dumps. Without it, you must do some digging with the Media Contents report. 2.3.1. /usr/openv/netbackup/bin/admincd/bpimmedia -U \ -mediaid MEDIA_NUMBER 2.3.2. This report is normally printed out for disaster recovery information and included in offsite storage packages. 3. Load the media 3.1. If we are on a system with Netbackup, you must request the media! 3.1.1. /usr/openv/bin/tpreq -ev MEDIA_NUMBER -a r -d \ 8mm -p POOLNAME -f /tmp/tape 3.1.2. POOLNAME is either WPGstandard or Offsite (caps count) 3.1.3. /tmp/tape can be any new file name of your choice 3.2. If we are on a stand-alone system with no netbackup, installed and the binaries are available, just load the tape. 4. Rewind the tape: 4.1. /usr/bin/mt -f /tmp/tape rew 5. Choose the file from the media report and fast forward to it 5.1. /usr/bin/mt -f /tmp/tape fsf file_number 5.2. If the file is file number 37, you can fsf 37 to reach it. This will skip the Media Header (which is really the first file on the tape) 5.3. Do NOT go to the IDX files. They are useless to you. 5.4. Please note that Netbackup breaks the backups into files that are less than or equal to 2000 kilobytes in length. A backup may, therefore span several files. Locate the Backup id and Fragment number for clues to locating a complete backup. You MUST use the multi-volume option of tar to extract a backup spanning several files. 6. Move ahead one record (to skip the Backup Header) 6.1. /usr/bin/mt -f /tmp/tape fsr 1 7. Run Netbackup's tar to list or extract! 7.1. To just list the contents, run with the -t option 7.1.1. /usr/openv/netbackup/bin/tar -t -v -f /tmp/tape -b 512 7.2. To extract the entire contents, without a leading /, use -x 7.2.1. /usr/openv/netbackup/bin/tar -x -v -p -f /tmp/tape \ -b 512 7.3. To extract a specific directory, without a leading /, specify the target directory (NOTE: you can use gnu's tar instead of Veritas Netbackup's tar; it will work fine): 7.3.1. /usr/openv/netbackup/bin/tar -x -v -p -f /tmp/tape \ -b 512 DIRECTORY_NAME 7.4. To extract entire contents from multiple fragments, without leading /, use -M 7.4.1. /usr/openv/netbackup/bin/tar -x -M -v -p \ -f /tmp/tape -b 512 7.4.2. Tar will automatically position the tape to the next file, assuming it to be the next volume (or fragment) of the backup. It will prompt you to "Prepare volume #X and hit return:". Just hitting return will continute. If the next fragment is on another tape, then you must rewind the current tape, unmount it, replace with the right tape, fast forward, and fsr to the right file to continue the restore. 7.5. Note that the block size is 256000, so you can pass 512 to tar (actually, it's really 500, but tar figures it out to be 500 anyway) 7.6. When you are doing multiple restores, note that you may have to rewind the tape (/usr/bin/mt -f /tmp/tape rew) and fast forward (/usr/bin/mt -f /tmp/tape fsf #) to get to the next backup. The device is a "No Rewind" device, so that consecutive backups can be accessed by just moving ahead one record (/usr/bin/mt -f /tmp/tape fsr 1) and re-running tar. (Be mindful of multiple-volume backups when searching for the right backup!) 7.7. Netbackup's tar's help can be accessed for additional options (such as NOT stripping the leading /): 7.7.1. /usr/openv/netbackup/bin/tar +help 8. Rewind and Eject the media 8.1. /usr/bin/mt -f /tmp/tape rew 8.2. /usr/openv/volmgr/bin/tpunmount 9. Example: 9.1. I need to restore all of sybprod:/opt2 from an incremental backup done in the early morning of 13 October 2001. A look on the Images on Media report (that was printed for the duplicates done later that morning) tells me that an incremental backup of Sybprod is on tape 190022. It has a title of "sybprod_ 0973059916" and shows that it consists of an IDX file and 5 fragments. A look on the Media Contents report tells me that fragment 1 of "sybprod_0973059916" is file number 113 and that the other fragments follow consecutively. 9.2. I find my Unix machine with an AIT drive and install the OS. I also mount the Netbackup Server CD and install the software but don't configure anything. I discover that the AIT drive is configured as /dev/rmt/0 (or /dev/rmt/0n for no rewind). 9.3. I put in tape 190022 into the AIT drive. I rewind the tape for good measure. 9.3.1. /usr/bin/mt -f /dev/rmt/0 rew 9.4. I fast forward 113 files on the tape 9.4.1. /usr/bin/mt -f /dev/rmt/0n fsf 113 9.5. I move over the Backup Header 9.5.1. /usr/bin/mt -f /dev/rmt/0n fsr 1 9.6. I change to the root directory and make sure that /opt2 exists and has lots of space. 9.6.1. cd / ; ls -ld opt2 ; df -k /opt2 9.7. I begin the restore (note that I'm using a blocking factor of 500, which produces the same result as 512) 9.7.1. /usr/openv/netbackup/bin/tar -x -M -v -p -f \ /dev/rmt/0n -b 500 /opt2 9.7.2. I am prompted 4 different times to hit return and dutifully do so. 9.8. I check everything out to make sure it is ok and celebrate!