Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a linux dedicate server with access using ssh and plesk. I don't have enough space on my server that I can zip my all folder and files and then scp them on my local computer.

Is there a bash command which can zip remote files on my local drive directly?

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

If your "local drive" is a linux client, you might just use a remote tar command to print the output to stdout (the default, an explicit option specification would be "-f -")and pipe it to a local tar that reads from stdin (explicit option "-f -" again) like that:

ssh your.dedicated.server 'tar -czf - /my/files/to/back/up' | tar -xzf -

When using the "-z" option, Tar will compress your data with gzip's default compression level (6). If you want a better compression rate and have CPU cycles to spare, you might use "-j" instead, but if it is an old/virtual machine with a fast link, you might end up with an overall lower transfer rate.

Oh, and as an edit: you might specify the -C (compress) option with SCP, this will use gzip as a compression algorithm as well, although the compression rates usually will be slightly lower than with a tar/gzip combination. It is less to type and you will get nifty progress indicators as a bonus.

share|improve this answer
    
probably more like: ssh your.dedicated.server 'tar -czf - /my/files/to/back/up' > my.local.tarball.tgz –  glenn jackman May 16 '11 at 16:10
    
I can't see if he rather prefers a compressed tarball or the file/directory structure of the original on his "local drive". If it is the earlier, you are right of course. –  the-wabbit May 16 '11 at 16:17
add comment

I'm not exactly sure what your problem is. Can you explain a bit more?

Anyway, see the -r and -C options to scp. That allows you to copy a file tree recursively and compress it on the wire. Afterwards, you can always zip it on your local machine.

If you really want to zip it on the fly, at least with tar it works like

ssh yourserver 'tar cvzf - /path' > local.tar.gz

share|improve this answer
add comment

I'm not sure if there is a command you can run to actually have the data zipped up to your local machine during transfer, but can't you just transfer over some things unzipped, enough to where you can then delete the originals on the remote machine, then zip the rest, and send them? Then you can just unzip them at your local machine, put them all together as they were, and re-zip them?

Sorry, hope I'm understanding what you are trying to accomplish.

share|improve this answer
    
No need to do the work manually where the machine can do it for you. –  the-wabbit May 16 '11 at 16:25
    
Very true. Just thought it might have been something he needed to do in a hurry, guess thats what I get for assuming. –  Chris-D May 16 '11 at 16:56
add comment

Your Answer

 
discard

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.