Copy entire tar file from tape to disk without extraction

December 9, 2011 at 07:36:42
Specs: Linux
I would love to know whether there is a command available that can copy an entire tar file from tape to disk, without having to extract the contents of the tar to a work area, then retar that work area into a single tar again. I thought this would be straightforward, but after much googling, apparently (to quote from the E*Trade baby) this is "frowned upon in this establishment!" Does anyone know of a solution to replicate a tar file this way? Thanks in advance.

See More: Copy entire tar file from tape to disk without extraction

Report •

#1
December 9, 2011 at 10:08:51
I have never tried it with Linux, but back in the day, in Unix I used the dd command to copy content from the tape device:

dd if=/dev/rmt/0u of=<new file name> bs=32k

Of course, /dev/rmt/0u is the tape device name. you might have to change that. The bs is the block size and you may have to play with that, but 32k is a good place to start.


Report •

#2
December 9, 2011 at 20:19:56
You can easily try nails dd approach to see if it work.

It also may need to be known what format this tape is in. Was it a linux tar command to a standard device? Or is this vax or unix or such?

I haven't used tape like that in decades. I feel pretty sure you can just copy it off as it is in a tar state. It has been placed on the tape in a format that can be used.

I just don't remember how to do it.

In any case even if you had to use tar you could then pipe that command back to tar or some compression to a file or folder.

I am looking up how to do it but I am sure you can just access the tar as a file.

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#3
December 12, 2011 at 14:15:26
Yes, this is just a standard tar operation on Linux to tape, etc. I did play around with dd but I'm not getting any sort of consistent results. I think there needs to be a degree of confidence with using tar to put the data on tape and using dd to export it with integrity. The tar extraction from tape piped to a new tar file sounds like a workable arrangement, however it does generate some questions - where does the intermediate data go, and what if the tar file on tape had a lot of data, does that overflow the pipe resource quota at some point? Thanks.

Report •

Related Solutions

#4
December 12, 2011 at 18:33:46
Maybe dd with some input block size and output with block size and padding?

I'd try the tar and pipe it back to tar to a file.

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#5
December 12, 2011 at 23:31:15
I'm not sure you can pipe the output of tar in that way. The output (to StdOut) is the list of files being extracted, not the content of the files.

Report •

#6
December 13, 2011 at 06:11:44
I'll try playing around with the piping option. To me though, this should just be an option that comes with the tar command. The tar command lets you create, extract and list tar files, but not copy them. Sure, when tar files are on disk, the cp command takes care of copying them, but when the tar is on tape, AFAIK, there is no "copy" command available to replicate the file from tape to disk. Perhaps the fine folks who maintain the tar utility can consider providing this option in the future. Thanks.

Report •

#7
December 13, 2011 at 07:31:02
"To me though, this should just be an option that comes with the tar command."

I'm not sure why. It is a fairly unusual request to want to copy a tar file from tape to disk. Normally people are interested in the contents of the tar file rather than the file itself.

You could try putting a request to the people who maintain tar; or you could even program the improvement yourself. But I suspect the dd command will do what you want. That's the Unix philosophy - rather than making programs all singing and dancing behemoths, they are lean, individual utilities which do one job well.


Report •

#8
December 13, 2011 at 17:10:34
I feel pretty sure you can pipe almost any set of commands.

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#9
December 14, 2011 at 00:03:56
Having looked at the tar man page, there is actually an option --to-stdout to direct the extracted flies to StdOut. Using this switch, you are probably correct. I might do a test later to see of this works when piped back into another tar.


Edit: The --to-stdout works, but I can't see how to pipe the output back into the tar command. Perhaps someone cleverer than me knows the answer to that one.


Report •

#10
December 14, 2011 at 14:11:07
I was thinking of tar (something) | tar (something)

So it would be tar as in untar really to the pipe then tar again to put the file on some drive. Might be better to pipe to gzip or other archive.

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#11
December 14, 2011 at 23:22:41
But, again, you have the problem that tar doesn't take the file data from StdIn ( it takes the names of the files from there). I couldn't find any switch to change this.

Report •

#12
December 15, 2011 at 18:43:00
I had to double check this. I may have to try it. Pretty sure it will work.

http://www.bolthole.com/solaris/ksh...

http://php.ptagis.org/wiki/index.ph...
http://www.codingforums.com/archive...
http://en.wikipedia.org/wiki/Tar_%2...

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#13
December 15, 2011 at 23:19:01
Tarring to a pipe, and then untarring that pipe is no problem. It's a well-known way of moving a file system. But the requirement here is the opposite, which is a completely different thing. I'd be fascinated to hear of a proven method of doing this via pipes. My vote is still for "dd".

Report •

#14
December 16, 2011 at 07:49:21
I played around with dd and it does allow me to reproduce the tar file, although the byte size it creates on the output tar file seems to be rather excessive, which goes to the block size point I suppose. Again, I think even though dd command "can" do the replication, it would be helpful to have something definitive on the topic along with the rules of engagement between using tar to write to tape and dd to read those tars, as opposed to just hit or miss guessing with dd arguments, etc. I still think the better way to go is to add an option for this to the tar command. According to the man page on Linux, the author of tar is Mike Frysinger, but I'm not sure what the procedures are for submitting this suggestion...

Report •

#15
December 16, 2011 at 11:58:33
Send a message to bug-tar@gnu.org (although it says "bug" it deals with feature requests too). It's a mailing list, so you'll probably need to subscribe to it to see what response (if any) you get; in fact, it would be sensible to subscribe to the list and look at it before making a submission.

Here's the tar page on gnu.org: http://www.gnu.org/software/tar/

TBH, I wouldn't expect the request to be successful unless a lot of people say "that's a good idea". Alternatively, download the source code, write the new feature yourself and the submit it to gnu.org.


Report •

#16
December 20, 2011 at 13:40:40
Would cat command work? I assume the tape can be mounted and I doubt it is used raw but could be.

Maybe tpio?

http://www.bluehaze.com.au/unix/tpi...

dd is a bit by bit and to keep space small the way to go is by file based. tar in an archive or more than one could be on the tape. I assume that cat /dev/raw would be same as dd.

I know you don't want the pipe overheard but that is the normal way to do such a task.

1/3 of highway deaths are caused by drunks. The rest are by people who can't drive any better than a drunk.


Report •

#17
December 20, 2011 at 14:15:51
Thanks for all the replies - I've submitted the suggestion to the gnu folks.

Report •

Ask Question