5.5.05

One in the rsync...

So, rsync is your friend. You should hug it, and love it, and buy it a sticky bun and hot chocolate every now and then when its feeling lonely. Here's what I know about it:

/usr/bin/rsync -azv                -e /bin/ssh \ 
               --rsync-path=/usr/bin/rsync \ 
               /web_directory new.webserver.net:/web_directory

OPTIONS:

 -a    Archive mode (enables recursion and preserve everything)

 -z    Compress file data (gzip)

 -v    Verbose (see all the deets)

 -e    Specify the rsh/ssh to use

 -n    Do a dry run (just show what would be done w/o actually 
     doing it)

 /bin/ssh   Path to the ssh, used with -e above

 --delete   Delete files on new.webserver.net that don't exist on 
     old.webserver.net

 --rsync-path=... Path to rsync on new.webserver.net

 /web_directory Path to rsync from

 new.webserver.net:/web_directory
     Host and path to rsync on new.webserver.net

Executing this command as demonstrated here will result in a large output dumped directly to the screen. You can save these to text by appending:

> /tmp/rsync-new.webserver.net:web_directory.log

or something of the ilk. Of course, you can name your log files whatever you want, but I prefer overly descriptive names myself.

Here's a couple more examples:

1) Sync /web_dir on test server from production server (on production server)

rsync -azv --delete -e /usr/bin/ssh --rsync-path=/usr/bin/rsync \
  /web_dir test.webserver.net:/web_dir > \ 
 /tmp/rsync-test.webserver.net:web_dir.log

2) Sync from /web_dir/web_app on build server to production server (on production server)

rsync -azv --delete -e /usr/bin/ssh --rsync-path=/usr/bin/rsync \
 build.webserver.net:/dev_dir/web_app /web_dir/web_app > \
 /tmp/rsync-build.webserver.net:web_dir:web_app.log

3) Pretend to sync from /web_dir/web_app on build server to productions server (on build server)

rsync -azvn --delete -e /usr/bin/ssh --rsync-path=/usr/bin/rsync \
 /dev_dir/web_app production.webserver.net:/web_dir/web_app > \
 /tmp/rsync-production.webserver.net:dev_dir:web_app.log