[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Backing up the system



To make complete backups, I think it's best to create a mirror image (dd
if=/dev/hdax of=/dev/hdbx),  it has a good $/GB considering what drives cost
today, and you know you have an exact replica, down to the bit.  Besides the
downsides that Karsten mentioned for this, you also have to worry about
possible disk geometry problems if you have to replace the disk.  It's best to
write down the disk geom. params when using this method and save it as a file
with the image file.  Complete image files are the quickest way of restoring
from a disaster assuming the disaster didn't also kill you image files.

Attached is a daily tape backup script for non rewinding SCSI tape devices
I wrote.  Back up popular directories as stated by Karsten.  This is simply a
different script but nonetheless handy for comparison.  I find tapes much more
handy for larger scale disaster recovery scenarios, make a backup, verify it,
take the tape offsite somwhere.  You can fit an amazing amount of data in a
small space using tapes.

about my script... you can run the script by hand or in a cron job.  This
particular script backed up a web server farm.  Each server scp'd (secure
copied) files to a local repository on the server that ran this script (and
obviously had the tape device connected to it), tapes where cycled daily.  You
could use amanda, BRU, and other systems, but tar and this script does the job
just beautifully (keep it simple).

just my 2 cents.

--
#!/bin/sh
exec 2>&1
#
# This assumes all files have been copied over and a file exists called
# /root/filestobackup, make note of trailing slashes as they affect tar
output.
#
# Features:
# logs to syslog and uses indentation for easy reading of logs
# checks to make sure each step worked correctly
# emails administrators with notifications of failure(s) or success and size
of
# backup to monitor long term usage
# compiles all files first, then writes to tape (faster)
# trap statements to clean up properly if kill'd
#

# Variables and trap statements (just in case)
ADMINS="jason.hammerschmidt@maclaren.com, hammerschmidt@home.com"
COMPILEDIR="/tmp/backup$$"
TAPEDEV="/dev/st0"
trap 'rm -f $COMPILEDIR >/dev/null 2>&1' 0
trap "exit 2" 1 2 3 13 15

wall "Starting automated backup process, expect slow down of system..."
mkdir $COMPILEDIR
cd $COMPILEDIR
logger "Starting backup to tape script..."
echo "Starting backup to tape script..."
echo "We'll be backing up the following files and directories:"
cat /root/filestobackup

logger " Starting tarring files..."
tar cvf $COMPILEDIR/`date -I`.tar `cat /root/filestobackup`
        RESULT=$?
        if [ $RESULT -ne 0 ] ; then
                logger "Failure in backup script couldn't run tar" $RESULT
  echo "tar puked this " $RESULT | mail -s "Failure in tape backup script
could not run tar" $ADMINS
                exit "Failure doing tar" $RESULT
 fi
logger " Finished tarring files..."

logger " Starting to bzip2 tar files..."
echo "Finished tarring files, now we will bzip2 them"
bzip2 $COMPILEDIR/`date -I`.tar
        RESULT=$?
        if [ $RESULT -ne 0 ] ; then
                logger "Failure in backup script couldn't bzip tar" $RESULT
                echo "bzip2 puked this " $RESULT | mail -s "Failure in tape
backup script could not bzip tar file" $ADMINS
                exit "Bzip2 failied " $RESULT
        fi
logger " Finished zipping files..."
echo "Finished zipping files... Beginning tape functions"
logger " Begining tape functions..."

# uncomment this section if you have to erase your tapes first.  Some tapes
# need erasing first, most dont.
#logger "  Erasing Tape contents..."
#mt -f /dev/st0 erase
#        RESULT=$?
#        if [ $RESULT -ne 0 ] ; then
#                logger "Failure in backup script"
#                echo $RESULT | mail -s "Failure in tape backup script"
$ADMINS
#                exit $RESULT
#        fi
#logger "  Done Erasing Tape contents..."

logger "  Copying files to Tape..."
tar cvf $TAPEDEV $COMPILEDIR/`date -I`.tar.bz2
        RESULT=$?
        if [ $RESULT -ne 0 ] ; then
                logger "Failure in backup script"
                echo $RESULT | mail -s "Failure in tape backup script" $ADMINS

                exit $RESULT
        fi
logger " Finished writing to tape successfully..."
echo "cleaning up..."

SIZE=`ls -la $COMPILEDIR/\`date -I\`.tar.bz2`
echo "Successfully completed backup script, size of backup was" $SIZE | mail
-s "Successfully completed backup script" $ADMINS

rm -fr $COMPILEDIR/
logger "Finished back to tape script sucessfully."
echo "Done."


--
Jason Hammerschmidt - "Sapere Aude" - Jason.Hammerschmidt@Maclaren.com
MacLaren McCann Interactive - direct 416.643.8560


Attachment: backuptotape.sh
Description: Bourne shell script


Reply to: