When I originally build my NFS/NAS server I decided to go for a software-based RAID 1 array for the OS install itself. The storage drive was RAID-5 based but that is a different story. I can’t recall the specifics exactly but I do remember a few times having difficulty booting off of the second drive and during the rebuild thought a slightly different design would be worth a try. Since I had two identical drives from the array I figured the mirroring was a good idea, it was just the mdadm driver that I wanted to avoid. Instead a manual mirror with rsync was in order.
I did base my design upon some very good backup reference information. Plus with this way it would be easy to boot from if ever needed and take tar archives of the data without dealing with file consistency or modification issues.
Here’s how it works:
Duplicate the partition table for your source/OS drive (or whichever drive you want to use) . I did this manually with fdisk, but you could easily do it with:
dd if=/dev/<src> of=/dev/<dest> bs=512 count=1
Obviously replacing <src> and <dest> with the source and destination disks – it is critical you have them in the right order. However this won’t work with extended partitions as they have additional tables. You can read more here if you like.
Configure fstab to use UUID’s if not already done. Have the partitions on the mirror/destination disk mounted under a common mount point, eg: /backup.
# /dev/sda2 UUID=50128bb8-7aa4-4b45-b2c6-5e406c641004 / ext3 # /dev/sda1 UUID=f0cd2333-868c-4a31-8386-554070cdfc5e /boot ext3 # /dev/sda3 UUID=62f0da84-24af-485b-8cab-81c90e740156 /home ext3 UUID=adbd21df-2d93-4868-8272-74c4fd98ca71 /backup ext3 UUID=32be4980-0bac-463c-bf54-2d2eb59e3942 /backup/boot ext3 UUID=936c69b7-f076-4140-9e80-142858907862 /backup/home ext3
I also have the /backup partitions mounted read-only and only change when actually doing the backup.
Configure the correct settings in the script. We want to specify the source partitions to backup.
UUIDS=( 50128bb8-7aa4-4b45-b2c6-5e406c641004 f0cd2333-868c-4a31-8386-554070cdfc5e 62f0da84-24af-485b-8cab-81c90e740156 ) BKUP_MNT=/backup
You can download the script or view it in my wiki. Feel free to leave comments and suggestions. I did some basic debugging and seems to work just fine for me, but I am not held responsible for any consequences.
[...] been using my rsync mirror script for a few weeks now and have implemented an additional one or two tweaks after deploying it on my [...]