Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a website on my local computer running Mac OS X. I am wondering if there is any built-in command that I can run in the Terminal that will upload that website to my webserver through SFTP. Installing new commands through MacPorts is a possibility. A big bonus would be that it only uploaded the files that needs to be updated and not everything else.

It would also be nice if I can tell it to delete the files on the server that no longer exists locally once in a while.

Any good tips?

Update: This question asked about both SFTP and FTP, but I've only gotten an answer regarding SFTP. rsync seems to do it very well when the server supports ssh, but if I have understood correctly, rsync does not support FTP. I'm still looking for a good solution for FTP, so have opened a different question for it.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use rsync. It's purpose is to sync remote/local files.

rsync -avz --delete source-address destination-address

Please read the documentation in order to understand what are the available options and how to use it. (like the difference between "dir" and "dir/")

Of course, you can also use scp -r, but rsync is the best solution.

share|improve this answer
    
would that do one or two-way synchronization? –  Svish Mar 29 '10 at 18:54
    
Rsync does one way sync from source to destination. –  fideli Mar 30 '10 at 3:21
    
That's one-way sync (and from your question, it seems you need one-way sync). For two-way, I personally use Unison (cis.upenn.edu/~bcpierce/unison). But two-way sync has other types of problems (a file has been changed on both hosts, what to do?) and thus is a bit harder. –  Denilson Sá Mar 30 '10 at 19:58
    
yes, it is one-way that I want. Does it support ftp somehow? –  Svish Apr 5 '10 at 16:23
1  
Rsync is a different protocol than FTP. The big strength of rsync here is that it determines pretty close to the minimal set of changes to send for each update by comparing destination to source. FTP can not do that. The easiest way to set up FTP would require sending the entire site for each update. Alternatively, one could track recent changes at the source, but I guarantee you will, at some point, get out of sync with what should need to be sent and what actually needs to be sent. If your site is small, sending the whole thing is fine. –  mpez0 Apr 5 '10 at 17:23

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.