[ale] scp, rcp, tar questions
hirsch at zapmedia.com
hirsch at zapmedia.com
Thu Feb 14 17:36:14 EST 2002
Charles Marcus writes:
> OK,
>
> I've gotta copy some stuff (home directory for one of our users) from a
> remote server down in Fla to my local server here in Atl.
>
> I have never used the tar beyond untarring tarballs when installing
> software, and never used the rcp command. I am having trouble figuring out
> the syntax, and the man pages aren't much help. I'd spend the time trying
> to figure it out myself, but this guys will be here in the morning, and I
> was just told about it, so hope someone can hold my hand...
>
> So, what would the syntax be for tar/gzipping up a directory? I *think it
> would be:
>
> tar -z /home/username/* tarfile.name
tar -czf /home/directory tarfile.tar.gz
> One problem is, I'm on a private IP, NAT'd through to the internet, logging
> into another computer with a private IP using NAT.
>
> So, when doing the remote copy (rcp), how do I specify the host names? Just
> use the IPs of the routers doing the port-forwarding?
Any name that resolves to the given machine should work, including the
IP number. It would be better to use scp, though.
> Would it be:
>
> rcp -pr user at xxx.xxx.xxx.xxx:/home/tarfile.name user at xxx.xxx.xxx.xxx:/home
>
> Should I use scp?
Yes. Even better, use tar and ssh (or rsh):
machine1> tar -czf - /home/directory | ssh machine2 (cd /home; tar -xzf - )
should do the trick. You may substitue rsh for ssh if you must. The
-f option means use a file, and if the file is named - use stdin or
stdout. So the first tar puts the output on stdout and the second tar
reads it from stdin. You never need to create a tar file.
Even easier, assuming ssh (or rsh) is setup correctly,
machine1> rsync -a -e ssh /home/directory machine2:/home
should copy all of directory to machine2:/home. In the future, if you
need to update it:
machine1> rsync -a -e ssh --delete /home/directory/ machine2:/home/directory/
Please note the location of all '/'s in that line. It is very easy to
forget one of them and get files in the wrong place.
--Michael
---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be
sent to listmaster at ale dot org.
More information about the Ale
mailing list