2007-04-23

CD Backup Script (Updated)

Bellow is an updated version of my CD backup script that I developed a while back:



#!/bin/sh
#
version="1.5.5"
version_date="Mon Oct 30 15:59:14 WST 2006"
version_author="Dean Bergin (dean.bergin@gmail.com)"
version_desc="A basic automated CD backup script"

master()
{
# initiate a variable to hold the iso filename as a sting
iso_filename=backup-`date +%Y%m%d`.iso
# Check for existance of an iso with the same datestamp
# and rename acordingly
if [ -f /u1/${iso_filename} ]
then
mv /u1/${iso_filename} /u1/old.${iso_filename}
mkisofs -v -J -V backup -A '' -N -sysid '' -o /u1/$iso_filename $backup_dir
else
# TODO: Add more checking to see if the files we have for
# a backup will fit onto a CD

# If all is fine then go ahead and make the iso
mkisofs -v -J -V backup -A '' -N -sysid '' -o /u1/$iso_filename $backup_dir
chmod 0740 $iso_filename

fi
}

archive()
{
# Initialise a list of directories to include in the backup cycle
dirlist="/boot /etc /root /tmp /var"
# Dynamically create tarballs based on the directory names
for dirname in $dirlist
do
tar cfvz ${backup_dir}${dirname}.tgz $dirname
done
# This section deals with specific exceptions for dirictory names
# that requires additional filename formatting
tar cfvz ${backup_dir}/usr-home.tgz /usr/home
}

# Directory cleaning function that will automatically delete
# all files in the $backup_dir automatically. It is assumed that
# previous backup iso's have been performed
clean()
{
for file in `ls ${backup_dir}`
do
rm -rf $file
done
}

# Initialise $backup_dir and give it a value
backup_dir="/u1/backup"
# call the custom made functions
clean
archive
master



DISCLAMER:
This script has been tested, and works fine (on my own system).
Feel free to copy and modify this script to suit your own needs, but don't come crying to me if it doesn't work on your system! There is no warranty or any of that stuff and the above code is provided "as-is". Perhaps you should write your own scripts then you won't have to worry about all this legal stuff :)

No comments:

 
Google+