2

I have been using Transmit.app to sync my local website directory to /home/public at my remote webhost.

However I am fed up doing this graphically, clicking 10-15 times, everytime I make a small change to my website.

How can I do this from the command line? I have ssh access to my remote webhost. I have never used rsync some pointers might be helpful.

2 Answers2

1

Something like this:

rsync -avh --delete /local/directory username@remotehost:/home/public

This will create directory within /home/public. If you however want to have the contents of directory directly in /home/public use something like (note that trailing slash):

rsync -avh --delete /local/directory/ username@remotehost:/home/public

Check out man rsync for more options. The ones used above:

  • --delete will remove nonexisting files on the remote host, so be careful about what you transfer.
  • a is for "archiving" and should be useful in most cases
  • h will enable human readable file sizes

Some additional options you may want to use:

  • --progress to see the current progress as well
  • --dry-run to see what would theoretically be transmitted (but don't actually transmit anything)
slhck
  • 228,104
1
rsync -avhe ssh --delete /home/user/dir/ user@remote.host.com:dir/

Quite simple and straightforward.

Hopefully you use git in your development process, then you can just use it instead.

More info on rsync here:

http://www.linux.com/news/enterprise/storage/8200-back-up-like-an-expert-with-rsync

To deploy with git:

http://philsturgeon.co.uk/news/2010/02/Deploying-websites-with-Git