[CLUE-Tech] Spanning backup
signal9 at earthlink.net
signal9 at earthlink.net
Thu Mar 14 22:46:05 MST 2002
If anyone is interested, I have an ok backup scheme that addresses
some of these problems, and saves on CDs too. Once a week, all my
pertinent data and configs are backed up to CD, and every other day,
a simple 'find' powered incremental backup is made to a Zip100 disc.
#!/bin/ksh
#
# This script makes either full or incremental backups of user data
# and system configuration files.
# On the first day of every week, a full backup of user's home directories
# and system configuration files is made to CD-R. Each night after, this
# script checks for differences between current files and files previously
# backed up to CD-R, and records changes to zip disk.
#
# This script is to be run as root from cron.
#
################### backup.sh #####################
#
# User Data:
DATA="/home/melissa /home/signal9 /home/NoJo /home/photos /home/scratch"
#
# System Configs:
CONFIG="/etc /root /boot /vmlinuz /System.map"
#
# Incremental Backup List
LIST="/tmp/backlist-$$.txt"
#
# Location of backup tar-balls
ARCHIVE="/tmp/backup"
#
set $(date) # Grab date variables for time-stamping
#
if [ "$1" = "Sun" ]; then
# Sunday full backup of all data and configs
#
mkdir /tmp/backup
tar cfz "/tmp/backup/data_full_$2-$3-$6.tar.gz" $DATA
tar cfz "/tmp/backup/config_full_$2-$3-$6.tar.gz" $CONFIG
#
# Burn .iso of archives to /dev/scd0
#
IMG_SIZE=`mkisofs -R -q -print-size $ARCHIVE 2>&1 \
| sed -e "s/.* = //"`
echo $IMG_SIZE
[ "0$IMG_SIZE" -ne 0 ] && mkisofs -r $ARCHIVE \
| cdrecord speed=2 dev=0,0,0 tsize=${IMG_SIZE}s -data -
#
# Clean up last week's backups and this week's temp files
#
mount /mnt/zip
rm -r /tmp/backup
rm -f /mnt/zip/*_diff*
#
# Report on backup status
#
DATA_SIZE=`du -csh $DATA`
DATA_SIZE_OUT=`echo $DATA_SIZE | cut -d" " -f11`
CONFIG_SIZE=`du -csh $CONFIG`
CONFIG_SIZE_OUT=`echo $CONFIG_SIZE | cut -d" " -f11`
mail -s "Backup Status" signal9 <<EOF
$1, $2 $3, $6
Full backup of system configuration files and user data successful.
Overall Disk Usage
----------------------------------
User Data.....................$DATA_SIZE_OUT
Config Files..................$CONFIG_SIZE_OUT
Per User Disk Usage
----------------------------------
/home/melissa.................`echo $DATA_SIZE | cut -d" " -f1`
/home/signal9.................`echo $DATA_SIZE | cut -d" " -f3`
/home/NoJo....................`echo $DATA_SIZE | cut -d" " -f5`
/home/photos..................`echo $DATA_SIZE | cut -d" " -f7`
/home/scratch.................`echo $DATA_SIZE | cut -d" " -f9`
EOF
else
# Daily incremental backup to zip disk
#
mount /mnt/zip
#
find $DATA -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT "/mnt/zip/data_diff_$2-$3-$6.tar.gz" $LIST
rm -f "$LIST"
#
find $CONFIG -depth -type f \( -ctime -1 -o -mtime -1 \) -print > $LIST
tar cfzT "/mnt/zip/config_diff_$2-$3-$6.tar.gz" $LIST
rm -f "$LIST"
#
umount /mnt/zip
#
# Report on backup status
#
mail -s "Backup Status" signal9 <<EOF
$1, $2 $3, $6
Incremental backups of system configuration and user data successful.
EOF
fi
More information about the clue-tech
mailing list