Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am accessing a shared hosting account through Putty / SSH. The account is pretty full, 300 MB below its quota. I need to make a full backup of all data present on the account. Creating a bzip2 file using

tar cjf archive.tar.bz2 directory/* 

fails because there is not enough space for the tar.

Does anybody know a way to create a tar file and "stream" it to a local file on my PC? Through putty or any other SSH tool?

share|improve this question
up vote 6 down vote accepted

If you have cygwin, then you can just run something like this on your local machine:

ssh user@host 'tar cj directory' > /cygdrive/c/archive.tar.bz2

and it will put the tar archive in c:\archive.tar.bz2

If you don't have cygwin, you can do the same thing with plink (part of PuTTY) from a command window;

plink user@host 'tar cj directory' > c:\archive.tar.bz2

(I'm assuming you're on Windows if you're using PuTTY - if you're on Linux, just run the ssh command)

share|improve this answer
Cheers @James. This seems to be doing the trick (still downloading, notice the slight difference in quotes): 'tar' cj directory > c:\archivename.bz2 – Pekka 웃 Mar 18 '10 at 18:07

Use WinSCP.

share|improve this answer
Good point, but I would like to compress the data on server side into a tarball to save traffic. I think WinSCP can't do that. Still, the next best thing. – Pekka 웃 Mar 18 '10 at 18:08
you wont get a tar achive, and you'll be copy unix files to a windows filesystem. That's not the best idea. – The Unix Janitor Mar 18 '10 at 18:08

Quotas are enforced on a per filesystem basis. If /tmp has enough space available, there's a good chance you can use it.

To pipe tar through SSH:

ssh server "tar -cf - /home/user" | tar xvf -

share|improve this answer

on unix/linux it's very easy to push a tar stream (or any stream) over the network.

PUSH: (if your logged into the machine where the data is)

tar zcvf - /wwwdata | ssh "cat > /backup/wwwdata.tar.gz"

PULL: (logged into your workstation for instance)

ssh tar cf - -C sourcedir . | tar xvf -

ssh tar cf - -C sourcedir . | cat > /backup/mywwwdata.tar

now, on windows, you maybe able to do this with the ssh that comes with

share|improve this answer
Why would you cat data already being output to STDOUT? – Warner Mar 18 '10 at 18:16

I'm using plink as a test to 'pull' the entire tree from my iphone via usb networking just to test it.

Works great!

plink user@host 'tar' --create --bzip2 --verbose / > x:\iphonebackup\iphone.tar.bz2

iPhone processor has teh slowness, so it comes in spurts. But, it's working perfectly.

NOTE: Leave out the "--verbose" part for quiet/save bandwidth. I included it so that I'd get something on my screen to let me know it was working right. Spewing all that information would defeat the purpose of saving pipe/speed. I only used it to confirm function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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