Operating System - HP-UX
1834232 Members
2378 Online
110066 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

Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

and sorry,, I misread the mt command... bsf simply means backward spacec 1 file when set to 1. Unless you need the no-rewind option (0mn), just go with the default and drop the mt command all together
KapilRaj
Honored Contributor

Re: Backup and restore with tar and mt

Hi ,

It is as simple as this .

When you use /dev/rmt/?mn where ? stands for instance number of your tape. The media does not rewind after backup. but beware when u eject the tape physically out of the drive ,it goes to the begining. Let's forget abt that part , ie. assume u are not taking the tape out of the drive.... the backup happens goes this.... Scenario where i am trying to backup "kaps.txt" file in to the tape everyday.

Monday .... tar cvf /dev/rmt/0mn ./kaps.txt
Tuesday .... tar cvf /dev/rmt/0mn ./kaps.txt
Wednesday .... tar cvf /dev/rmt/0mn ./kaps.txt

Now on wednesday if u wanna restore Monday's kaps.txt, u need to do the following

mt -t /dev/rmt/0mn bsf 3
tar tvf /dev/rmt/0mn (for listing )
tar xvf /dev/rmt/0mn (for extracting)

Now, if u wanna read tuesday's content , u need to perform the following,

mt -t /dev/rmt/0mn fsf 1
tar tvf /dev/rmt/0mn (for listing )
tar xvf /dev/rmt/0mn (for extracting)

Hope it's pretty clear now

kaps
Nothing is impossible
Deshpande Prashant
Honored Contributor

Re: Backup and restore with tar and mt

HI
while reading from tape, you will be better of by starting at starting point (bot).
#mt -t /dev/rmt/0mn rew
#mt -t /dev/rmt/0mn fsf 1
#tar tvf /dev/rmt/0mn

Thanks.
Prashant.
Take it as it comes.
Steve Labar
Valued Contributor

Re: Backup and restore with tar and mt

You may also consider redirecting the output of the table to a text file. Otherwise, the tar command will show the files on the screen just as fast as it can read them from the tape. If you redirect output you can review the file easier.
tar tf /dev/rmt/0m > tuesday_table.list

Good Luck.
Steve
Mauro_8
Frequent Advisor

Re: Backup and restore with tar and mt

Hi,

I??m still having problems...

I did this,

1) tar cvf /dev/rmt/0mn test.tar
appears the message:
a test.tar 20 blocks

2) mt -t /dev/rmt/0mn bsf 1
return 1 file, in the start point of test.tar, I hope.

3) tar tvf /dev/rmt/0mn
Tar: blocksize = 0; broken pipe?

Unfornately it goes wrong. I was expecting to see test.tar

Any ideas ?

Regards,
Mauro
Allan Pincus
Frequent Advisor

Re: Backup and restore with tar and mt

Last time I did something like this, the tape had already rewound after the tar command, so even though /dev/rmt/0mn is not supposed to be rewinding, maybe it is anyway, and then you get the error with the mt command since you can't rewind.

One thought would be to put down a larger file on tape, suppressing the rewind, and physically pull the tape out to see that it is truly NOT rewound, just to convince yourself that the device driver is leaving the tape at the end point.

Just a thought.

- Allan
Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

do this instead of your last try:

tar -cvf /dev/rmt/0m /etc/hosts .... this will create a tar archive of the hosts file on the default device (/dev/rmt/0m)... don't mess with no-rewind option (/dev/rmt/0mn), you don't need it.

to check it...

tar -tv
-or-
tar -tvf /dev/rmt/0m

don't try and get too creative with bsf, etc... it will be really hard to keep straight when you get a bunch of files on one tape anyway.

Allan Pincus
Frequent Advisor

Re: Backup and restore with tar and mt

Ted,

I think Mauro's point is he is putting multiple days of archives on the same tape, but if he wants to see the archive from 3 days earlier, he rewinds the tape 3 files back to retreive it. That's why he's leaving the tape at the end point.

My gut tells me his tape drive is rewinding.
Ted Ellis_2
Honored Contributor

Re: Backup and restore with tar and mt

Yup... guess my point was why try and keep track of where you have to go on a tape... create archives with unique names that are then appended to an existing archive. Not a problem and then you can just scroll the entire tape from the beginning and know what is there... no need to manually scroll around the tape. Seems tough, especially if you have a whole bunch of these... I was just trying to get him to simplify what he was doing to see a successful tar creation and review...

I'll hold off on any more comments here until our suthor comes back with more