Operating System - HP-UX
1753776 Members
7039 Online
108799 Solutions
New Discussion юеВ

Backup and restore with tar and mt

 
SOLVED
Go to solution
Mauro_8
Frequent Advisor

Backup and restore with tar and mt

Hi,

Everyday I do a backup with tar cvf current_date.tar ./ in the current directory, where current_date is the time backup runs. So each day I have one tar file. I want to know how can I access the tape to display the files ? Supose today is friday and I want to restore the backup of last tuesday, how can I return three days and then restore ? I know it should be something like this :
mt -t /dev/rmt/0mn bsf 3 and then tar tvf ... Am I right ?

Can I backup files using fbackup and tar in the same tape ?

Thanks all,
Mauro
18 REPLIES 18
Ted Ellis_2
Honored Contributor
Solution

Re: Backup and restore with tar and mt

the ommand you have here is not creating a tar file on a tape... but a tar file in whatever directory your profile happens to specify... to create a tar file onto tape:

tar -cvf /dev/rmt/

the default device for tar is /dev/rmt/0m.... if you run an ioscan -funC tape, it will report the tape drives that are available... if the one you want to use is not the default, then you will need to specify the device:

tar -cvf /dev/rmt/ target....
MANOJ SRIVASTAVA
Honored Contributor

Re: Backup and restore with tar and mt

Mauro


tar cvf will overwrite , you need to use tar rvf to append to the tape , and then you cando the mt fsf and resoter , the better way would be to use fbackup or omni back


Manoj Srivastava
Mauro_8
Frequent Advisor

Re: Backup and restore with tar and mt

ok, but this command finishes what can I do to see this file in the tape ?

Thanks,
Mauro
Anil C. Sedha
Trusted Contributor

Re: Backup and restore with tar and mt

Mauro,

If your data is not being overwritten, then you may use the following to verify your data in the tape.

tar -tvf /dev/rmt/0mn

then, restore by

tar -xvf /dev/rmt/0mn bsf 3

Regards,
Anil (hope this helps)
If you need to learn, now is the best opportunity
A. Clay Stephenson
Acclaimed Contributor

Re: Backup and restore with tar and mt

As has been mentioned, tar cvf current_date.tar ./ will not write anything to the tape but assuming that you get that changed to tar cvf /dev/rmt/1mnb ./ or whatever is your tape device then you would do a tar vtf /dev/rmt/1mnb to read the tar contents. Note that if you use mt to position the tape, you must use the no-rewind devices (and I suggest that you use the 'Berkeley-style' mnb no-rewind devices).
If it ain't broke, I can fix that.
Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

your original command syntax does not violate anything, so it will work, but it will not create a file onto a tape: you need to do the following to get your command corrected and then the following to either append or view what is on the tape:
# to create the original tape tar
tar -cvf /dev/rmt/ ./ (I prefer to use fully defined path names and not relative.
# to append to it
tar -rvf /dev/rmt/ ./ (again.. recommend full path names)
# to view
tar -tvf /dev/rmt/0m

Ted
Mauro_8
Frequent Advisor

Re: Backup and restore with tar and mt

I did:

1) tar cvf /dev/rmt/0mn test.tar
2) mt -t /dev/rmt/0mn bsf 1
3) tar tvf /dev/rmt/0mn

and received the message:
Tar: blocksize = 0; broken pipe?

What is it ?

Cheers,
Mauro
Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

drop the middle step.. you do not need to adjust the block size with mt in order to review a tar.... you ran the first tar with defaults and then changed a setting on the drive.... go ahead and rerun again and skip the mt part
Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

also.. did you create the test.tar file with a different archive command? Are you going to create the first tar image on file somewhere and then back it up? Example:

you want to backup the contents of /home on tape at default device /dev/rmt/0m

tar -cvf /dev/rmt/0m /home

that will create the tar image on the tape at device /dev/rmt/0m... and since this is the default tape device, the following will do the exact thing

tar -cv /home (drop the f and device since we use defaults)

to review what is now on tape:

tar -rv or tar -rvf /dev/rmt/0m