Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've been googling all morning trying to work this out to no avail, so hoping someone more knowledgeable can help! I've inherited a server that's backing up to a tape drive (/dev/nst0) using tar, and I need to restore from tape. What i've done so far;
1. Rewound the tape (mt -f /dev/nst0 rewind)
2. Tried to list the contents of the tape (tar -b 128 -tzf /dev/nst0) which gives the error:
Code:
gzip: stdin: not in gzip format
tar: Child died with signal 13
tar: Error exit delayed from previous errors
3. I took the 'z' out of the last command (tar -b 128 -tf /dev/nst0) and got the following;
Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
This would be the first time trying to restore from tape, and as far as I know the previous admin didn't test the backups so there's every chance it's never worked I suppose, but it may also be that i'm just doing something stupid. Help/ideas would be much appreciated
The error messages say that the tape is not in either tar format or gzip format. The other possibility is bzip2 format. Try using the -tjf parameter to see if the tape is in bzip2 format.
What's the extension on the file? If it is just .tar, then it may not be compressed at all. Granted someone can place any extension on a file and that doesn't necessarily make it true.
If it is merely a .tar file, then you can view it because it will then be a concatentation of the backed up files, with some added header and delimiter information. Tar means something like "Tape ARchive", if you make an unzipped tar of just two small text files you can look at the resulting .tar file and pretty much see the contents of your two text files. Same thing in this case if it's not a zipped archive, you should be able to see the files, just that it's likely a lengthy file it the backup was performed properly.
Another thing to check is how large is this file? Corresponding large WRT the files it is supposedly being a back up.
Update - The following command works (lists contents of tape):
Code:
tar -t --blocking-factor=128 -f /dev/nst0
So do I need to specify --blocking-factor=128 when trying to restore?
Yes, the only real difference between -t and -x is that -t lists where -x extracts.
The -b or --blocking-factor determines the block size used; which is probably meaningful to tape drives versus the rest of the world using tar.
Another thing that's occurring to me is that you never needed to have tried the -z parameter, when you list or extract the filename extension itself should determine for tar what form of unzipping (if any) is required.
Yes, the only real difference between -t and -x is that -t lists where -x extracts.
The -b or --blocking-factor determines the block size used; which is probably meaningful to tape drives versus the rest of the world using tar.
Another thing that's occurring to me is that you never needed to have tried the -z parameter, when you list or extract the filename extension itself should determine for tar what form of unzipping (if any) is required.
That makes sense, but i'm having difficulty with the restore. I'm running the following command in /Ext_1Tb and want to restore the complete 2011 dir as a test, but it doesn't work;
Code:
tar --blocking-factor=128 -xvf /dev/nst0 ./Ext_1Tb/2011
And the error:
Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
That makes sense, but i'm having difficulty with the restore. I'm running the following command in /Ext_1Tb and want to restore the complete 2011 dir as a test, but it doesn't work;
Code:
tar --blocking-factor=128 -xvf /dev/nst0 ./Ext_1Tb/2011
And the error:
Code:
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Archive contains obsolescent base-64 headers
I don't know what /dev/nst0 and ./Ext_1Tb/2011 represent; /dev/nst0 appears possibly to be the tape drive device. As far as I'm concerned, you don't need all that. My basic form for extracting from a tar file would be the following example, noting also that the easiest things to do are (1) If you don't know the contents or structure of an archive, use tar -tvf <tarfilename> to get a report on it, and (2) when you extract it, do so from the direction location where you wish to extract.
Example:
Code:
# Large tar file that starts at a high level directory, has a lot of files, and many sub-directories
$ cd $HOME
$ tar -tvf /media/tape-drive-mount-location/something.tar
./top-level/.
./top-level/sub-directory/.
./top-level/sub-directory/README
...
# And so forth
# What I learned here is that when this archive gets extracted in the normal manner, it will
# create "top-level" and the associated sub-directories starting at the point where I am
# located in my own directory structure. Note that you don't have to be in the location of
# the tar file, you can refer to it from a mounted storage location and extract it into a
# different directory, you can specify a target directory to place the results, but it's
# also easy just to be located in the target directory and run the command
$ tar -xvf /media/tape-drive-mount-location/something.tar
# Files get extracted into $HOME where you happen to be at the time
Note also that if the tar file is zipped and has a .gz, or .bz2 extension, tar will be capable of detecting this and perform the unzip operations as part of the extraction.
Once again, the easiest thing to do is the following:
- Go to the location where you wish to put the extracted files.
- Run "tar -xvf <tarfilename>
I don't know what /dev/nst0 and ./Ext_1Tb/2011 represent; /dev/nst0 appears possibly to be the tape drive device. As far as I'm concerned, you don't need all that. My basic form for extracting from a tar file would be the following example, noting also that the easiest things to do are (1) If you don't know the contents or structure of an archive, use tar -tvf <tarfilename> to get a report on it, and (2) when you extract it, do so from the direction location where you wish to extract.
Example:
Code:
# Large tar file that starts at a high level directory, has a lot of files, and many sub-directories
$ cd $HOME
$ tar -tvf /media/tape-drive-mount-location/something.tar
./top-level/.
./top-level/sub-directory/.
./top-level/sub-directory/README
...
# And so forth
# What I learned here is that when this archive gets extracted in the normal manner, it will
# create "top-level" and the associated sub-directories starting at the point where I am
# located in my own directory structure. Note that you don't have to be in the location of
# the tar file, you can refer to it from a mounted storage location and extract it into a
# different directory, you can specify a target directory to place the results, but it's
# also easy just to be located in the target directory and run the command
$ tar -xvf /media/tape-drive-mount-location/something.tar
# Files get extracted into $HOME where you happen to be at the time
Note also that if the tar file is zipped and has a .gz, or .bz2 extension, tar will be capable of detecting this and perform the unzip operations as part of the extraction.
Once again, the easiest thing to do is the following:
- Go to the location where you wish to put the extracted files.
- Run "tar -xvf <tarfilename>
Thanks for your reply, appreciated although i'm not getting anywhere.
/dev/nst0 is the tape drive (sym link to /dev/tape also)
/Ext_1Tb is where I want to restore the data to
I have no idea what the structure of the archive on tape looks like, or what it's called. I can't 'cd' to /dev/nst0 (but I guess that's normal?).
I don't know what /dev/nst0 and ./Ext_1Tb/2011 represent; /dev/nst0 appears possibly to be the tape drive device. As far as I'm concerned, you don't need all that.
He is trying to restore from tape, so yes, he does need all of that.
First off, if this is your BACKUP to TAPE command:
Code:
tar --create --blocking-factor=128 --totals --file=$dlt config.tar.gz
Then you have only backed up the file config.tar.gz
What do you get if you cd to your destination directory and run:
Code:
tar --blocking-factor=128 -xvf /dev/nst0 config.tar.gz
Without specifying the destination...
Last edited by szboardstretcher; 07-29-2014 at 08:24 AM.
Thanks for your reply, appreciated although i'm not getting anywhere.
/dev/nst0 is the tape drive (sym link to /dev/tape also)
/Ext_1Tb is where I want to restore the data to
I have no idea what the structure of the archive on tape looks like, or what it's called. I can't 'cd' to /dev/nst0 (but I guess that's normal?).
When you perform an ls on /dev/nst0 you should see the tar file name.
Change directory to /Ext_1Tb and extract using the full path and name of the tar file, full path is /dev/nst0, name of the tar file is the name of the tar file which you see when you perform a directory listing of /dev/nst0.
Code:
$ cd /Ext_1Tb
$ tar -xvf /dev/nst0/<tar-file-name>
Perhaps you're saying that /dev/nst0 is a symbolic link, then perform a long listing of /dev/nst0 to determine where the link is pointing too.
Code:
$ ls -l /dev/nst0
But it sounds as if /dev/nst0 is merely a symbolic link to /dev/tape.
What you're missing is that you need to refer to the actual .tar file, you can't just give the "directory" name where the file exists, you need to give the tar file name.
Here is a test I JUST ran successfully on my tape array:
Code:
# Load a tape and rewind
mtx -f /dev/changer status
mtx -f /dev/changer load 0 1
mt -f /dev/st0 rewind
# Tar and compress a text file to the tape
tar -czvf /dev/st0 /root/testing1.txt
# Look at the contents of the tape
tar tvf /dev/st0
# Restore the file from the tape
mkdir /tmp/restore && cd /tmp/restore
tar -xzvf /dev/st0 root/testing1.txt
What I am concerned about is that you cannot list the contents of the tape. Once we have that part nailed down, restoration is simple. If listing has worked, please provide the list contents.
Last edited by szboardstretcher; 07-29-2014 at 08:46 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.