pippin,
I have the script modified and working. I am using it with an IDE CD-RW, and backing up only /home and all it's sub-directories.
You will need to create a backup folder in your /tmp directory
mkdir -p /tmp/backup
You may need to adjust your CD-RW device number based on the result of cdrecord -scanbus
This script should be useful for a server in a small office where there is not a huge amount of data. It would not be hard to modify it to use re-writable DVD media.
Be careful how much data you re trying to save, it limits you to 580MB.
I set it up to open the tray when complete so the office staff will know it done.
I need to look at sending a message to a “key operator” if an error occurs.
I tried to set the directory to backup to “/home/e-smith/files/ibays”, and it did not like it. It sees the “-” as some sort of delimiter, and it chokes on it.
Here is the modified script
-----------cut---------------------
#!/bin/bash
# backup
#------------------------------------------------------------------------------
# Script to enable easy backup some important users files
# Uses multiple CD-RW Disks to rotate backups
# Original script by Alan Keates, and was found at
#
http://www.faqs.org/docs/gazette/backup.html#------------------------------------------------------------------------------
# The original backup directory contained files for boot and recovery,.
# These have been removed
# I plan on using this script in SME servers placed in small offices, where small sets of data require
# backup
Backup_Dirs="/home"
Backup_Dest_Dir=/tmp/backup
Backup_Date=`date +%b%d%Y`
Image_File=/tmp/backup.iso
declare -i Size
# Create tar file with todays Month Day Year prepended for easy identification
tar cvzf $Backup_Dest_Dir/$Backup_Date.tar.gz $Backup_Dirs &> /dev/null
# Start backup process to local CD-RW drive
echo "Backing up $Backup_Dest_Dir to CD-RW Drive - $Backup_Date"
echo "Creating ISO9660 file system image ($Image_File)."
mkisofs -o $Image_File $Backup_Dest_Dir
# Check size of directory to burn in MB
Size=`du -m $Image_File | cut -c 1-3`
if [ $Size -lt 650 ]
then
echo "Size of ISO Image $Size MB, OK to Burn"
else
echo "Size of ISO Backup Image too Large to burn"
rm $Backup_Dest_Dir/$Backup_Date.tar.gz # Remove dated tar file
rm $Image_File # ISO is overwritten next backup but cleanup anyway
exit 1
fi
# Burn the CD-RW
# Use best speed for CD-RW disks on YOUR system
echo "Burning the disk."
# Set dev=x,x,x from cdrecord -scanbus
cdrecord -v -eject speed=4 --dev=ATA:1,0,0 --blank=fast $Image_File &> /dev/null
Md5sum_Iso=`md5sum $Image_File`
echo "The md5sum of the created ISO is $Md5sum_Iso"
# Could TEST here using Md5sum_Iso to verify md5sums but problem is tricky.
echo "To verify use script md5scd, this will produce the burned CD's md5sum"
echo "run this as User with backup CD in drive to be used for recovery."
echo "This verifies not only the md5sum but that disk will read OK when needed."
# Remove image file and tar file
echo "Removing $Image_File"
rm $Image_File
echo "Removing : $Backup_Dest_Dir/$Backup_Date.tar.gz"
rm $Backup_Dest_Dir/$Backup_Date.tar.gz
echo "END BACKUP $Backup_Date"
echo "Be sure to place this backup in the RED CD case and previous CD in GREEN"
echo "------------------------------------------------------------------------"
exit 0
-------------------cut---------------------
Bob