5

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?

Pekka
  • 2,178
  • 3
  • 20
  • 32

5 Answers5

6

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)

James
  • 7,643
  • 2
  • 24
  • 33
  • 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
2

Use WinSCP.

Teddy
  • 5,204
  • 1
  • 23
  • 27
  • 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
1

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 -

Warner
  • 23,756
  • 2
  • 59
  • 69
1

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 username@backupserver.org "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 http://www.cygwin.com/

The Unix Janitor
  • 2,458
  • 15
  • 13
1

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.