Thursday, March 25, 2010

Mirroring entire directory with "mirrordir" command

Note :- "mirrordir" setup has been tested on CentOS / RHEL 5x versions only.

Introduction :

mirrordir copies files that are different between the directories control and mirror to the directory mirror. Files whose modification times or sizes differ are copied. File permissions, ownerships, modification times, access times (only if --access-times is used), sticky bits, and device types are duplicated. Symlinks are duplicated without any translation. Symlink modification and access times (of the symlink itself, not the file it points to) are not preserved. Hard linked files are merely copied.

mirrordir command supports strong stream cipher encryption and Diffie-Hellman key exchanges with several possible key sizes.

Hand's On Exercise :

yum install mirrordir

Create a new directory named "backup"
cd /
mkdir backup

Now, mirror existing data onto "backup" directory.For Example, We will take backup of "nishith" directory.

mirrordir -v nishith nvbkup
Output is as shown below.

mirrordir: ---verbose--- copying file: /nvbkup/file5
mirrordir: ---verbose--- copying file: /nvbkup/file1
mirrordir: ---verbose--- copying file: /nvbkup/file2
mirrordir: ---verbose--- copying file: /nvbkup/file3
mirrordir: ---verbose--- copying file: /nvbkup/file4
mirrordir: ---verbose--- all hardlinks located
mirrordir: Total mirrored: 5kB

If you rerun the "mirrordir" command, only the updated files are copied.

mirrordir -v nishith nvbkup
Output is as shown below.

mirrordir: ---verbose--- copying file: /nvbkup/file6
mirrordir: ---verbose--- copying file: /nvbkup/file1
mirrordir: ---verbose--- all hardlinks located
mirrordir: Total mirrored: 5kB

For More Information, "man mirrordir"

You can use "cron" script for automated backup of your data directories.




No comments:

Post a Comment