up vote 3 down vote favorite
share [g+] share [fb]

I have a little dilemma here...

I needed to move about 70 GB worth of files from one of my servers to the other, so I decided that tarring them up and sending the archive would be the fastest way.

However, the receiving server only has 5 GB of space left after receiving the tar archive.

Is there some way I can extract the tar 'in-place'? I don't need to keep the archive after it has been extracted, so I was wondering if it is possible to do this.

Edit: It should be noted that the archive has already been sent, and I'd like to avoid resending via a different method.

link|improve this question

75% accept rate
feedback

2 Answers

% tar czf - stuff_to_backup | ssh backupmachine tar xvzf -

this translates to:

  • tar and compress 'stuff_to_backup' to stdout
  • login to 'backupmachine' via ssh
  • run 'tar' on the 'backupmachine' and untar the stuff coming in from stdin

i personally would use 'rsync over ssh' to transfer the stuff because you can continue transfering stuff if the connection breaks:

% rsync -ar --progress -e 'ssh' 'stuff_to_backup' user@backupmachine:/backup/

which will transfer everything from 'stuff_to_backup' to the 'backup' folder on the 'backupmachine'. if the connection breaks, just repeat the command. if some files in 'stuff_to_backup' change, repeat the stuff, only the difference will be transfered.

link|improve this answer
See my edited question – Charlie Somerville Jun 25 '10 at 14:04
@Charlie Somerville: yes, you left the important part out in the first place. :) – akira Jun 25 '10 at 15:06
feedback

If the other machine has ssh, I would recommend you rsync as another alternative that does not use a tar file:

rsync -avPz /some/dir/ user@machine:/some/other/dir/

And be careful with the leading /

Edit update

Well, I see how this is now a great pickle if you are not able to delete it and recommence with rsync. I would probably try a selective extract and delete from the tar.

selective extract:

$ tar xvf googlecl-0.9.7.tar googlecl-0.9.7/README.txt
googlecl-0.9.7/README.txt

selective delete:

$ tar --delete --file=googlecl-0.9.7.tar googlecl-0.9.7/README.txt

However, it seems that you will spend a lot of time coding a script for this...

link|improve this answer
See my edited question – Charlie Somerville Jun 25 '10 at 14:04
See my edited answer... good luck :-/ – YuppieNetworking Jun 25 '10 at 14:25
Thanks for the edit. The files are actually named with numbers, so a quick for loop in bash might just do the trick. – Charlie Somerville Jun 25 '10 at 14:41
1  
@Charlie Somerville: you might have to start with the files stored at the end of the tar, otherwise you might end with tar creating a new archive ... so, delete the files from the end of the tar first. – akira Jun 25 '10 at 15:08
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.