Nightly backup using CD-ROM - how do i?

Anish Mistry mistry.7 at osu.edu
Thu Nov 11 18:09:31 GMT 2004


On Thursday 11 November 2004 11:45 am, you wrote:
> * Anish Mistry <mistry.7 at osu.edu> [20041110 03:21]: wrote:
>
> [snip]
>
> Hey Anish,
>
> Thank you so much for your script.
>
> I am not quite a newbie on Unix, but your script has gotten me lost,
> such that I feel like a newbie ;)
>
> Could you kindly explain to me, step-by-step, how it works, please?
>
> > #!/bin/sh
> > # the date
> > DATESTRING=`date +"%Y%m%d"`
> > BACKUP_DIR=/usr/local/var/backup
> > CD_DEVICE=/dev/acd0c
> >
Defining the date of the backups to copy, it assumes the current.  Set the 
directory where the already tar'ed files are locations, and also set the 
CDROM device.
> > # first check if there is enough space left on device
> > # mount
> > #/sbin/mount /cdrom
> > #CD_SIZE=700
> > #CD_FILL=`/usr/bin/du /cdrom | /usr/bin/cut -f 1`
> > # unmount
> > #/sbin/umount /cdrom
> >
This is just commented out since it I ended up no needing it.
> > cd $BACKUP_DIR
> > # get previous multisession info
> > MSINFO=`/usr/sbin/burncd -f $CD_DEVICE msinfo`
> > if [ "$MSINFO" != "" ]
> > then
> > MULTISESSION="-C $MSINFO -M $CD_DEVICE"
> > else
> > echo "First session."
> > fi
Here we probe the CD to get the last session's track info.  If there is not 
last session info, then that means that it's a blank cd so we don't add 
the multisession info to the mkisofs command.
> > # create the .iso
> > echo "Creating backup ISO..."
> > /usr/local/bin/mkisofs -r -J -quiet $MULTISESSION -o
> > $BACKUP_DIR/$DATESTRING.iso $BACKUP_DIR/$DATESTRING*.tar.gz # burn
> > backups to cd
We create an ISO offset with multisession info if available with the files 
in the backup directory that match the date string.
> > echo "Burning backups to $CD_DEVICE..."
> > /usr/sbin/burncd -f $CD_DEVICE -q -s 24 -m data
> > $BACKUP_DIR/$DATESTRING.iso fixate if [ $? -ne 0 ]
> > then
> >  echo "Sysadmin, I\'m sorry the backup failed." | /usr/bin/mail -s
> > "The sky is falling!" someemail at fake.com fi
We burn the iso to the CD, it the command returns non-zero then it goes 
into the if statement and sends off and email tell someone to change the 
CD.
> > # delete the .iso
> > echo "Deleting ISO..."
> > rm $BACKUP_DIR/$DATESTRING.iso
> > echo "Done."
> > exit 0
Cleanup and exit.

Hope that helps.
-- 
Anish Mistry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20041111/4c95fe3f/attachment.bin


More information about the freebsd-questions mailing list