Monday, July 11, 2011

How to synchronize files through a SSH shell to a unix server

I have my own server, but until today I'd just manually update the files I changed. Never once thought of writing a script to do it for me... Until today. Solution? RSYNC!


rsync -e ssh -avz ./FOLDER ssh.server.address:NEW_FOLDER_LOCATION/

rsync's speciality lies in its ability to analyse files and only copy the changes made to files rather than all files. This can lead to enormous improvements when copying a directory tree a second time.

-a Archive mode, most likely you should always keep this on. Preserves file permissions and does not follow symlinks.
-v Verbose, lists files being copied
-z Enable compression, this will compress each file as it gets sent over the pipe. 
-e ssh Uses ssh as the transport, this should always be specified.


Make sure that rsync is installed on both client and server machines. I've heard that rsync has problems with trailing spaces and characters, so notice that there is NONE on the folder, but there is one on the new folder location.

No comments:

Post a Comment