Re: Software RAID - bunny trail

From: Matthew Schumacher <schu@schu.net>
Date: Wed Sep 27 2006 - 14:02:46 AKDT

Ben wrote:
> Does anyone know if you can do software raid over two USB mounted
> externals? Has anyone here done it?
>
> <read: an old samba laptop in the closet for a fileserver with mirror drives.>
>
> -Ben
>
Ben, as Damien already pointed out there is no reason why it wouldn't
work as linux doesn't really care where the block device came from. In
fact the nbd (network block device) driver allows you to remotely use
another machines block device allowing you to run raid 1 on disks in two
different machines over the network.

That said, for home use I contend that raid 1 is the wrong technology.
Raid 1 only buys you fault tolerance not data safety. If you fat finger
the rm command or the file system gets corrupted, linux will happily
replicate that to your secondary disk. Because of this, raid 1 should
only be used when you need to wait until a maintenance window to replace
the failed disk. If a little down time is not a big deal using some
form of data rotation backup is far better as it will keep your data on
another file system, and if you use the rsync method you will have a
snapshot of your data for the last 7 days while only using up the space
of the data plus change.

I have attached a script that I wrote/hacked/borrowed that will take
care of your backups. Simply put the script on your system, edit the
/etc/rotateBackup.includes and put the name of the directories you want
to backup. Then edit the script and in the config section tell it where
you want it to write your backup.

I use this in my /etc/rotateBackup.includes:
bin
boot
etc
home
lib
man
opt
root
sbin
usr
var

It's simple, effective, and best of all only takes a few minutes because
it only touches files that changed. If you put it in cron it even
emails you the list of files that changed which is really handy if you
want to keep track of what changed on your file server.

schu

-- Attached file included as plaintext by Ecartis --
-- File: rotateBackup.sh

#!/bin/bash

#
# Schu's backup rotation script modified from http://www.mikerubel.org/computers/rsync_snapshots/
#

# user changable stuff
BACKUPSOURCE=/
BACKUPDEST=/mnt/backup
EXCLUDES=/etc/rotateBackup.excludes
INCLUDES=/etc/rotateBackup.includes

# make sure we're running as root
if (( `id -u` != 0 )); then { echo "Sorry, must be root. Exiting..."; exit; } fi

# make sure we have rsync installed
if ! which rsync > /dev/null; then
  echo You must have rsync installed to use this script.
fi

# if the excludes file does exist then touch it
if [ ! -f $EXCLUDES ]; then
  touch $EXCLUDES
fi

# if the includes file does exist then touch it
if [ ! -f $INCLUDES ]; then
  touch $INCLUDES
fi

# now rotate snapshots

# step 1: delete the oldest snapshot, if it exists:
if [ -d $BACKUPDEST/backup.6 ]; then
  rm -rf $BACKUPDEST/backup.6
fi

# step 2: shift the middle snapshots(s) back by one, if they exist
if [ -d $BACKUPDEST/backup.5 ]; then
  mv $BACKUPDEST/backup.5 $BACKUPDEST/backup.6
fi;

if [ -d $BACKUPDEST/backup.4 ]; then
  mv $BACKUPDEST/backup.4 $BACKUPDEST/backup.5
fi;

if [ -d $BACKUPDEST/backup.3 ]; then
  mv $BACKUPDEST/backup.3 $BACKUPDEST/backup.4
fi;

if [ -d $BACKUPDEST/backup.2 ]; then
  mv $BACKUPDEST/backup.2 $BACKUPDEST/backup.3
fi;

if [ -d $BACKUPDEST/backup.1 ]; then
  mv $BACKUPDEST/backup.1 $BACKUPDEST/backup.2
fi

# step 3: make a hard-link-only (except for dirs) copy of the latest snapshot,
# if that exists
if [ -d $BACKUPDEST/backup.0 ]; then
  cp -al $BACKUPDEST/backup.0 $BACKUPDEST/backup.1
fi;

# step 4: rsync from the system into the latest snapshot (notice that
# rsync behaves like cp --remove-destination by default, so the destination
# is unlinked first. If it were not so, this would copy over the other
# snapshot(s) too!
rsync -va -r --delete --delete-excluded --files-from="$INCLUDES" --exclude-from="$EXCLUDES" $BACKUPSOURCE/ $BACKUPDEST/backup.0

# step 5: update the mtime of hourly.0 to reflect the snapshot time
touch $BACKUPDEST/backup.0

---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Sep 27 14:03:14 2006

This archive was generated by hypermail 2.1.8 : Wed Sep 27 2006 - 14:03:14 AKDT