unix command help

Posted by: johnmcd3

unix command help - 04/10/2002 01:15

wondering if there is a way to do the following:

I have a directory on a university machine with a specific quota (couple hundred megs). Of this, there is a directory i want to preserve the exact structure of that is the majority of that device. thing is i can't tar the beast because i don't have enough room for the tar on the device. i need the tar onto another computer which i can either ftp or ssh to (maybe some otherstuff i don't know).

seems like the're should be a way via some command line manipulation to send (pipe?) the tar directly to some program which forwards it to the remote computer or something. this is kinda for my own education because i see i can copy the things as they are and then tar later, but still... any ideas?

John
Posted by: Roger

Re: unix command help - 04/10/2002 02:01

If you've got ssh, you should have scp. You can use that.
Posted by: tms13

Re: unix command help - 04/10/2002 03:32

As Roger says, use scp.

It might still be useful to know how to tar into a pipe, though. To do that, specify "-" as the destination file, thus:

tar cf - my/directory/

and at the other end:

tar xf -

For example, the following is the equivalent of cp -rp dir1/* dir2:

tar -C dir1 cf - . | tar -C dir2 xf -
Posted by: wfaulk

Re: unix command help - 04/10/2002 06:00

Some tar implementations only support the -C option on extract, so ``tar -C dir1 cf - .'' wouldn't work.
Posted by: wfaulk

Re: unix command help - 04/10/2002 06:02

In general, I'd use:

cd /sourcedir
tar pcf - . | ssh remotehost '(cd /destdir; tar pxf -)'

But scp works as well.
Posted by: TheAmigo

Re: unix command help - 04/10/2002 18:12

That's how I'd do it too, or keep a compressed copy on the other server:
cd /sourcedir

tar pcf - . | ssh remotehost 'cd /home/dir; bzip2 -c9 - >archive.tbz'

Posted by: johnmcd3

Re: unix command help - 05/10/2002 01:41

scp worked well, but this is very good to know. thanks.
Posted by: Roger

Re: unix command help - 05/10/2002 05:22

The other thing you can do, if you've got rsync and ssh is this:

rsync -e ssh -auv /source/dir/ [email protected]:/dest/dir/

Careful with those trailing slashes -- rsync uses them to decide whether you meant to copy the directory, or the contents of the directory.