Solarum – Information For Everyone

Aug

Rsync R Your Friend

  Print Print

Need to sync some files? Locally or remotely? How about re-thinking an old friend, rsync?

You may be like I was, and have discounted rsync for a long time due to the security risk imposed by running the “r” daemon on your servers. Guess what? You can not only use rsync to sync up local directories on the same server (this can be real handy for backups), but you can also sync from one server to another via SSH rather than the rsync daemon. This would be much like scp, only you can sync whole directory trees.

So. Let’s say you want to sync two local directories, how would you do that? Well, if we are syncing /export/datadir to /export/backupdir it would look something like this:

rsync -aruv /export/datadir/ /export/backupdir/

It’s just that easy. Now, those command line switches, what do they do? Check it out:

a = archive
r = recursive
u = skip files that are newer on the receiving end
v = verbose, tell me what's going on

There is another one that is good when syncing between two separate servers, and that is the “z” switch. This tells rsync to use compression during the file transfer thus saving bandwidth. Let’s see what the above would look like from one server to another, as if you are running the command from the server you are syncing to:

rsync -aruvhz --progress server1:/export/datadir/ /export/backupdir/

There are a couple other options there, did you notice? I have added the “h” which tells rsync to output information in human readable format (GB, MB, K, etc), and the –progress which tells rsync to report exactly that, the progress of each transfer. You can use these with local transfers too, mix and match as you see fit.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Technorati
  • Slashdot
  • Fark
  • blogmarks
  • email
  • Facebook
  • LinkedIn
  • Live
  • TwitThis
  1. Best Backup Tool For Budding Networks | Solarum - Information For Everyone Said,

    [...] a software install on the client by utilizing things like SMB (Samba or Windows Shares), rsync (see previous post about this cool tool), tar (for local files), and more.  The instructions and documentation are straight forward and [...]

  2. grsync - a great backup and file sync tool | Solarum - Information For Everyone Said,

    [...] be boring, but one day a good backup will save your butt, I guarantee it.  Previously I posted an article extolling the virtues of rsync, a very powerful command line tool for syncing files both locally and across networks via SSH.  [...]

Add A Comment

Pages

Articles