[ale] second disk backup

Eric Ayers eric.ayers at mindspring.com
Sun Apr 18 07:42:09 EDT 1999


Nick Lucent wrote:
> 
> I just got another hdd for my server, and Im wondering what the
> best/easiest way to perform mirroring on it is. Do I just setup a cronjob
> to to dd if=/dev/hda of=/dev/hdb ? There has to be a better way. Does
> anyone know of one?
> 
> Nick

A couple of the wizards at my office put together the follwoing 
script that does miroring to another partition using
'rsync' which should be faster, and less error prone than dd



#!/bin/bash
#
# script to mirror the root partition on bass
#

ERROR="0"

cd /

/bin/mount -o remount,rw /mirror
if [ $? != 0 ] ; then
        echo "Error $? from remounting /mirror read/write"
        ERROR="1"
fi

# this is a very mean rsync command as it deletes files that
# don't exist on /
# BUT, it keeps the mirror from filling up.
/usr/local/bin/rsync -aSogx --delete / /mirror
if [ $? != 0 ] ; then
        echo "Error $? from rsync command for /"
        ERROR="1"
fi

cp /etc/fstab.mirror /mirror/etc/fstab
if [ $? != 0 ] ; then
        echo "Error $? from cp /etc/fstab.mirror command"
        ERROR="1"
fi

/bin/mount -o remount,ro /mirror
if [ $? != 0 ] ; then
        echo "Error $? from remounting /mirror read only"
        ERROR="1"
fi

if [ "$ERROR" = 0 ] ; then
        echo "Mirror script completed sucessfully"
fi






More information about the Ale mailing list