LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-23-2002, 04:15 AM   #1
juno
Member
 
Registered: Sep 2002
Location: fdas
Posts: 100

Rep: Reputation: 15
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?
 
Old 10-23-2002, 08:44 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
Old 10-23-2002, 09:25 AM   #3
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
Old 10-24-2002, 12:07 AM   #4
juno
Member
 
Registered: Sep 2002
Location: fdas
Posts: 100

Original Poster
Rep: Reputation: 15
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.
 
Old 10-24-2002, 03:40 AM   #5
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
Old 10-24-2002, 03:59 AM   #6
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i decompress this tar.tar file? hmmm sounds new.. tar.tar.. help ;) kublador Linux - Software 14 10-25-2016 03:48 AM
c++ append data to file blizunt7 Programming 3 07-04-2005 01:47 AM
gave wrong syntax for tar as tar -cvzf file file.tgz how to recover the file gautham Linux - General 4 04-13-2005 04:15 AM
Trying to Append files to an already made Tar bluedevlx Linux - Newbie 10 11-04-2004 08:37 AM
append to file d-rez Linux - Newbie 2 06-20-2002 05:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration