ssh file transfers - how to?

Jay O'Brien jayobrien at att.net
Sun Jan 9 22:37:45 PST 2005


joseph kacmarcik wrote:

>>For purposes of discussion, I'm logged into the distant machine
>>as jay at distantmachine.net. I'm logged in to the directory /www/jay
>>and my localmachine directory (now empty) is /home/www/jay. I want
>>everything in the www/jay directory on distantmachine to be copied
>>as the home/www/jay directory on localmachine.
> 
> 
> this depends whether you want a backup or if you want to have a live copy, there
> are a few ways (more on that later).
> 
> for a backup, you could (test first please):
> ssh remotehost "tar cf - /www/jay" > /path/to/tarfile

Thanks, this will come later - It's now on my to do list.

> or for live copy, two methods would be:
> ssh remotehost "tar cf - /www/jay" | tar -C /home/www/jay -xf -
> scp -pr remotehost:/www/jay /home/www/jay
> 
> 

Interesting, I ran it with only the -r argument and saw the file 
date/times were current; I read the MAN page and found the -p 
argument, and found it worked as promised. Thanks for confirming!


>>My follow-on question is -- Is there a way to synchronize the local
>>machine with the distant machine if changes are made on the distant
>>machine, and vice-versa, on a generic basis, i.e. "distantmachine
>>is now the master, correct localmachine to agree"?
> 
> 
> if you're trying to get a working copy and not backup, use rsync. this would be
> much easier, and it's easy to make it bi-directional (or more).
> 
> there are many ways to do this, one is:
> rsync -azvprt -e ssh [user]@remotehost:/www/jay /home/www
> 

The rsync program sounds like what I will need once I get things working. 
I'm building a duplicate of my web site, here on my local computer, and 
ultimately it will be a working copy at a slightly different URL. 

> you could use -n and --progress when you're doing the debugging getting it right
> for your situation and environment.
> 
> you'll still be transporting over ssh, but IMO rsync is a better choice.
> 
> good luck!
> joe

Joe, thanks. I can't go wrong with the support team here on questions. 
This is fun!  

Jay 




More information about the freebsd-questions mailing list