Aug 22

rsync has very good exclusion support, which can come in handy for files that you really don’t care about sending to another host.  For example, lets say you wanted to create the /tmp directory on a remote node, but you didn’t want to copy any of the files over. You just wanted the directory to be there.

+ /tmp
- **/tmp/**

Put that into a file called, oh lets see /etc/rsync.exclude, and then call rsync with

rsync -auv –delete –exclude-from=/etc/rsync.exclude $SOURCE $DESTINATION

party on Garth.

Mar 27

Rsync has to be one of my favorite tools. It’s cross platform (a windows variant even exists) and it’s saved my bacon more times then I can count. rsync is designed, as the name somewhat implies, to synchronize file(s) across different hosts or directories. It handles permissions, ownerships, crazy file names and is a very complete tool. Two scenarios that I use rsync for a lot are syncing up my mp3 player and moving directories from one unix server to another. To sync two local directories (mp3 player example) I run the following

rsync -auv $SOURCE/*.mp3 $DEST

Pretty straight forward. rsync -a(keep permissions and ownership) -u(update files that already exist on the $DEST) -v(show me lots of output)

Taking that one step further, rsync can use ssh to move files between nodes. When using ssh, rsync is intelligent enough to move only the bits of the file that have changed. So if you have a 10 meg file that you want to sync but have only changed 1k of data on that file, rsync will move that 1k of data and then reassemble the file on the remote end to include those changes. Really really slick little program. You can move data between hosts like so

rsync -auv $SOURCE $USER@$HOST:$DEST

Again, pretty easy to understand. All we added was $USER@$HOST and a colon. Now files on $SOURCE will be copied over to $DEST using ssh as use $USER. I use this fairly frequently to upgrade my wordpress install when a new update comes out.