Koozali.org: home of the SME Server
Obsolete Releases => SME 7.x Contribs => Topic started by: pippin on December 19, 2006, 02:37:34 PM
-
Here is a script i found on the net i will test it later with CD/DVD using two CD Green/Red
#!/bin/bash
# backup
#------------------------------------------------------------------------------
# Script to enable easy backup of all important Linux files
# and also creates a customized system repair disk.
# Uses two CD-RW Disks labled "RED" and "GREEN to rotate backups
#------------------------------------------------------------------------------
# The backup directory already contains files for boot and recovery.
# One can add more - my Slackware 8.1 system backup is < 580MB.
Backup_Dirs="/home /etc /usr/local /opt /var /root /boot"
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 -b toms288.img -c boot.cat -r \
-o $Image_File $Backup_Dest_Dir &> /dev/nul
# 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
Speed=4 # Use best speed for CD-RW disks on YOUR system
echo "Burning the disk."
# Set dev=x,x,x from cdrecord -scanbus
cdrecord -v speed=$Speed blank=fast dev=1,0,0 $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
-
pippin.
Any further word on success on this?
Thanks
Bob
-
I cant make it to work
-
and did you look at the mondo rescue contrib ?
Unless I am wrong it should perform all of this perfectly
G.
-
and did you look at the mondo rescue contrib ?
Unless I am wrong it should perform all of this perfectly
G.
Yes i looked at the mondo rescue but as far as i know it doesnt support RAID so i guess its worthless making a image that doesnt work
-
pippin,
I am playing with the script, and have part of it working. At the moment the server I am working on does not have a CD-RW in it. Tomorrow it will. At the moment I have it creating the tar file. I am not going to be creating a bootable cd, because I want this only to back up some ibays.
I will post the modified script when I have it compleated.
Bob
-
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
-
If you want to burn DVD's replace
cdrecord -v -eject speed=4 --dev=ATA:1,0,0 --blank=fast $Image_File &> /dev/null
with
growisofs -dvd-compat -Z /dev/cdrom -use-the-force-luke -R -J $Image_File &> /dev/null
This will burn +RW and -RW DVD's. The DVD's are blanked each time and ejected after burning.
You will have to modify the part of the script that checks the image size to take into account the increased size of the DVD.
Jon
-
Thanks JonB. That may prove helpful in the furture.
Bob
-
Can you tell us that are fairly new to sme how to take that script from here and implement it into a server?
Thanks
-
Give me a couple of days and I will write a detailed "How To".
Bob
-
I am testing this script now using dvd-r and so far it looks like it works.
Thanks crazybob :D
-
Hi guys,
I'm using the script, but I have a problem.
When writing it just write the .iso file... not the ISO content.
I just commented out the mkisofs line and inserted the growisofs line as recommended.
Any ideas why ?
BTW: I try to change growisofs line to:
growisofs -dvd-compat -Z /dev/cdrom=$Image_File -use-the-force-luke -R -J &> /dev/null
[
Moved the $Image_file to after device line and put a = signal as seen on so many web sites.
-
Hi guys,
I'm using the script, but I have a problem.
When writing it just write the .iso file... not the ISO content.
I just commented out the mkisofs line and inserted the growisofs line as recommended.
Any ideas why ?
This line means "put the file on the DVD":
growisofs -dvd-compat -Z /dev/cdrom -use-the-force-luke -R -J $Image_File &> /dev/null
And this means "MAKE a DVD of the file":
growisofs -dvd-compat -Z /dev/cdrom=$Image_File
I Have the script working now with DVD-R, i can for some reason not get it to blank my DVD+RW. It could be the media. But main thing is, it's working.
Per
UPDATE: It was for some reason the media. I tried with a DVD-RW and it works fine.
-
This line means "put the file on the DVD":
growisofs -dvd-compat -Z /dev/cdrom -use-the-force-luke -R -J $Image_File &> /dev/null
And this means "MAKE a DVD of the file":
growisofs -dvd-compat -Z /dev/cdrom=$Image_File
Thanks by the info. This did the trick.
Jáder