Wednesday, August 17, 2011

rsync in Batch mode

Batch mode can be used to apply same set of changes to many identical system. Suppose same of tree of a filesystem has to be replicated a number of hosts. Updates in one tree has be propagated to many hosts. In order to achieve this rsync can be used in batch mode. The --write-batch option tell rsync client to store in a batch file all the information needed to repeat this information against the other.

To apply the recorded change rsync has to be run with --read-batch option by specifying the same batch file. One thing also need to keep in mind that one bash file also get created in this process. Let us put this in an example command

root#rsync --write-batch=lists -a host:/source/dir /testdir

root#rsync --read-batch=lists -a /datadir

What is archive mode in rsync ?

As you know when i apecify -a option with rsync that means i want to apply rsync command in archive mode. Archive mode considered as most suitable for taking backup. Putting -a basically a shortcut of bunch of switches which includes follwings

-r recursive

-l copy symlinks as symlinks

-p preserve permission

-t preserve modification time

-g preserve group

-o preserve owner

-D device specials

And which exclude followings

-H preserve hard link

-A preserve ACLs

-X preserve extended attribute

So how concise and smart to use -a instead of mentioning above given bunch of switches.