Piping archive to remote host
I wanted to do something like this:
Take a local directory, - tar gzip/bzip2 it - ssh + cat it to a remote machine The only problem is, the only guide I found on the 'net was Code:
Backup with local compression and remote storage I can't use a local temp file expressly because the resulting tgz > free space. Sorry for the banal question, I've never been really good with piping. *blush* |
I assume you're using the Linux.com article as your guide?
I'd imagine that using "tar cjf" would work - the "j" flag adds bzip2 compression, as shown in the tar man page. . . Altho I believe the example you show is indeed making the TMPFILE file at the remote site. Just swapping "gzip" for "bzip2" would probably work |
try something like this:
tar cvf - localdir/ | ssh user1@remotehost "gzip -c > backup.tgz" (note: not all systems has the compress option - i'm doing this on AIX so the gzip redicrection :) |
For moving directories (and subdirectories) between computers, I like to use scp , like this:
scp -pr /path/to/directory hostname:/path/to/destination Or, if you just want to move one file: scp -p /path/to/file hostname:/path/to/destination Hope this helps. |
yes, why not just use scp? it uses the same authentication as the any other ssh connection (e.g. ssh-ageant works)....
|
tredegar, satinet, thanks for your replies but you probably glanced over my original post a little quickly :) I needed a way to pipe a local folder to a tar.gz on a remote machine, like oneandoneis2 and born4linux mentioned.
Thanks to all who replied, of course! PS For other things, I love scp, it's great, too bad it doesn't compress inline. |
this code wont work:
tar cf - dirname | gzip -c | ssh remotehost "cat > ${TMPFILE}.tar.gz" how are you defining TMPFILE? what are you cating? i'm not sure that gzip produces an output as such to pipe into ssh. i dont understand where cat comes into this. are you wanting to create an archive or expand it at the other end?? if you want to tar accross a network you would using something like: tar cf - dirname | ssh remotehost '( tar xfB - )' or are you wanting to create a gzip at the other end? how can you cat and archive or tar ball?? |
All times are GMT -5. The time now is 12:21 AM. |