LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   tar append file (https://www.linuxquestions.org/questions/linux-general-1/tar-append-file-33514/)

juno 10-23-2002 03:15 AM

tar append file
 
I want to use the same tape for several tar backups ,
I use กฐ tar -rvf tape_device abc.txt กฐ , it can't append the file abc.txt to the tape, how to append the backup to the end of archive?

Mik 10-23-2002 07:44 AM

Hmmm according to the documentation the tape should be positioned at the start of the tar file for that to work. But I just tried it on a DDS drive on linux but it doesn't seem to do anything. I'll see if I can try and find out some more or maybe try it on a different platform.

Mik 10-23-2002 08:25 AM

Well if I look at what it's writing to tape then it is actually appending the file after the archive. But there remains a eof marker still in between. This causes it to look as if the first archive ends before the last added file.

I found this when running 'info tar':

--append' cannot be performed on some tape drives, unfortunately, due to deficiencies in the formats those tape drives use. The archive must be a valid `tar' archive, or else the results of using this operation will be unpredictable.

juno 10-23-2002 11:07 PM

Hello !

Am not able to append to an archive on tape. Using the command:
tar cvf /dev/st0 file1

writes the file1 to the tape. It can be seen using the command:
tar tvf /dev/st0

Using the command:
tar rvf /dev/st0 file2
seems to do something, file2 pops up on screen but
tar tvf /dev/st0
shows that only file1 is on the tape.

file2 does not seem to be written on /dev/st0

Thanks for any help.

Mik 10-24-2002 02:40 AM

Well like I said before, the second file is actually written to tape. But somehow tar isn't able to properly overwrite the previous end of tar marker. So when reading the data back it stops at what was the end of the first archive. The data that is written after this is the next file but tar can't see it as a valid tar file anymore because it's not complete.

You are using the rewind tape device so the head will be positioned at the beginning of the archive like it should. But like they said in the info pages, it's not always possible to append to an archive on tape. What tape drive are you using? The things I tried was with a SDT-7000 (DDS-3) tape drive.

But why do you have to place everything in one archive on tape? Is it not suffiecient if you place multiple tar archives on the tape? To do this you will have to use the non rewind device (/dev/nst0) to make sure you are able to start after the last archive. Something like this:

mt -f /dev/nst0 rewind
tar cvf /dev/nst0 file1
tar cvf /dev/nst0 file2

The above commands would rewind the tape. Then the first archive is written without rewinding the tape after it is completed so you can write the next tar archive right after it. If you want to later just read the second archive you could do something like:

mt -f /dev/nst0 rewind
mt -f /dev/nst0 fsf 1
tar tvf /dev/nst0

Those are all basic mt and tar commands which I hope you where already familiar with. Hope some of that helps somehow.

Mik 10-24-2002 02:59 AM

Ok well I tried a few more things and I managed to append to a tar archive on tape. Just couldn't accept the fact that it didn't work. It seems that if the blocksize tar is using and the physical blocksize which the tapedrive are set to aren't the same then it's not able to append data to an archive properly. Probably because it's still got some empty blocks which make it see the end of archive to early. Anyways you have to either set the block size of tar to match the tape blocksize, or set the tape blocksize to that of tar.

tar uses a default blocksize of 512 * 20. As far as I can see the tape drive defaults to a blocksize of 512. So you can either archive with the commands:

tar cvbf 1 /dev/st0 file1
tar rvbf 1 /dev/st0 file2

or you can first set the tape blocksize and then archive as you where before:

mt setblk $((512 * 20))
tar cvf /dev/st0 file1
tar rvf /dev/st0 file2


All times are GMT -5. The time now is 12:21 PM.