[wplug] CD Burner Program

Wise, Jeremey WISEJ at PIOS.com
Tue Nov 26 08:05:00 EST 2002


Intro: My name is Jeremey Wise I live in Sunny Cleveland Ohio. I work for a
large company who focuses on enterprise system designs. As one of my product
repertoires I work with Linux. To keep my Linux skills up I help out a small
"mom and pop" company out with their systems. I have build a small SAMBA
server with a few shares and am working on a backup design for them. It has
the following criteria
1) Cheap
2) Small capacity (needed for office documents)
3) User friendly Windows interface for restore
4) No system administrator interaction in the even of a loss of data

I have posted this to the Cleveland Linux User group to no avail. The reason
I am going through all this is that their does not exist any tool to backup
a small SAMBA server onto CD media in such a way that a Windows user could
restore the data themselves. All the backup technologies on the market rely
on AFIO or CPIO and this would require a Linux system (or
Cygwin) but in either case would require a recompilation of all the media in
the backup BEFORE they could pull out their file(s). I want a method in
which they could put a CD in. Looks at a file called TOC and browse a
familiar tree (i.e. matching one they are use to seeing) and select the
file(s) they wish to restore. Then use WinZip to unpack them back to the
location of their choice.

The problem is I am missing some important pieces of logic in my script. I
have tried to document the process flow so you can follow my reasoning but I
do not know how to fill in the 'magic' pieces.

#!/bin/bash
# CD Backup Script
# By Jeremey Wise 11-5-02
# Version 0.3
# This script should be located in /mnt/backup
# This script assumes you are root level, have tar and space in /mnt for
backups cd /mnt/backup # Gettomg the backup directory structure created by
the date so it is easily tracked echo Making Backup Directory Coresponding
to Date mkdir /mnt/backup(date +%Y-%m-%d) cd /mnt/backup/(date +%Y-%m-%d)
echo date (date +%Y-%m-%d)>/mnt/backup/(date +%Y-%m-%d)/Backup.log

# Make a backup of the boot partition including MBR because it is small and
important echo Generating Boot Partition Backup >/mnt/backup/(date
+%Y-%m-%d)/Backup.log dd if=/dev/mda1 of=/mnt/backup/(date 
+%Y-%m-%d)/BootPartition.img

# Build a listing of all files with their path to be backed up echo
Generating MasterFileBackup List find /home /var/log >/mnt/backup/(date
+%Y-%m-%d)/masterfilelist

# Set counter to track which CD number is being generated COUNTER=0

# Start the process of building the CD archive by checking if their is
anything needing backup if [ls -s /mnt/backup/(date
+%Y-%m-%d)/masterfilelist |grep ='  0'] ;
        then ($COUNTER+=1) ;

#Magic happens here to insure 2 things - that the backup in progress does
not exceed 650MB and/or the master file list is no zero line (i.e. backup
complete)
	if [ls -sh /mnt/backup/tmp|grep <= 650M] ; or [ls -sh
/mnt/backup/(date +%Y-%m-%d)/masterfilelist|grep ='  0'] ;

#Magic below to generate a file that catalogs those files compressed and
added to current archive in tmp dir, while prepping master file list for
next parse by removing top line (file just processed)
	then (yank first line in masterfilelist & fork one copy into TOC
file & one to set $file) |gzip -9cf '/mnt/backup/tmp/'$file'.gz ;

fi ; 


# Now that we have reached 650MB or are done with the backup we will
generate the ISO image and prompt the user to insert media echo "Starting
ISO Compiled Fullbackup_'$COUNTER'.iso" >/mnt/backup/(date
+%Y-%m-%d)/Backup.log ; mkisofs -r -l -o /mnt/backup/(date 
+%Y-%m-%d)/Fullbackup_'$COUNTER'.iso /mnt/backup/(date +%Y-%m-%d)/tmp
/mnt/backup/(date +%Y-%m-%d)/Backup.log echo "ISO Compiled
Fullbackup_'$COUNTER'.iso" >/mnt/backup/(date +%Y-%m-%d)/Backup.log

# Remove temp directory so we can procesd in generating the next CD if
needed echo "Returning for Next CD Build>/mnt/backup/(date
+%Y-%m-%d)/Backup.log
rm -rf /mnt/backup/tmp

#Majic to return to counter line above and incriment counter


# Now that ALL the needed ISO images are created we wait for backup Manager
to come into work so we can start promting them to change media for final
burn. echo "Begining CD Burn Process" >/mnt/backup/(date
+%Y-%m-%d)/Backup.log

# Below are various methods to get the user's attention. Pick one or many
depending on how anoying you wish to be. echo "Please Insert Blank CD into
drive and Press <F10>on Server the Keyboard" |mail -s "Backup Request"
BackupMGR at Acme.com  
echo "Please Insert Blank CD into drive and Press <F10>on Server the
Keyboard" |smbclient -M Station1

# Majic here for user to press a key on the keyboard and have it continue
with this script. if [User pressed <F10> on server keyboard] & '$COUNTER'
>0] ;
        then
	cdrecord -speed=8 -dev=0,1,0 -eject -dao -pad -padsize=150s
/mnt/backup/(date +%Y-%m-%d)/Fullbackup_'$COUNTER'.iso ;
	($COUNTER-=1)
	else 
	# Last CD Burned So we can exit
	echo "Backup Completeted Succesfully" >/mnt/backup/(date
+%Y-%m-%d)/Backup.log
	less /mnt/backup/(date +%Y-%m-%d)/Backup.log|mail -s "Backup
Request" BackupMGR at Acme.com
	echo "Backup Completeted Succesfully"|smbclient -M Station1
	
fi ;

# Prompt the user to lable the CD and insert a new blank
echo "Please label ejected CD Fullbackup_'$COUNTER' & (date +%Y-%m-%d) then
insert blank CD into drive and press <F10>on Server the Keyboard" |mail -s
"Backup Request" BackupMGR at Acme.com  
echo "Please label ejected CD (Fullbackup_'$COUNTER') & (date +%Y-%m-%d)
then insert blank CD into drive and press <F10>on Server the Keyboard"
|smbclient -M Station1

# All done

If you wish to reply back to or have an idea of a portion of the script
issues please feel free to modify and RSVP to me or the group and I will try
to compile the suggestions. I will of course supply everyone a copy of the
final product as I believe we all support small windows / SMB environments
where backups are an issue.

Thanks,

Jeremey Wise (440)-519-6006
(CNE,MCSE,CSE)
Pioneer-Standard Electronics, Inc
wisej at pios.com
 




More information about the wplug mailing list