Automated DVD Backup
Today I would like to share with you, a little script that I use every week. I have four rewritable DVD that I use in rotation to backup important directories of my server at home. All I have to do is to leave one of these DVD+RW in the dvd drive and a backup of my important directories will be taken at regular interval. I have schedule a cron job that run tree times a week, to backup to DVD directories that are important to me. This is by no way a replacement of a full system backup like Mondo rescue, Storix or Acronis, but they represent to me the directories that are subject to change more often. I must specify that the command used in this script require using a DVD+RW to work.
The script need some tools included in the ‘dvd+rw-tools” package, just be sure you install it before running the script
Fedora or RHEL 5 # yum install 'dvd+rw-tools' RedHat Enterprise 3 or 4 # up2date 'dvd+rw-tools'
Now, let’s schedule our script to run every Monday, Wednesday and Friday at 3am. I have chosen to place the script in a directory (filesystem) name /linternux in the sub-directory ‘bin’, but you can place it where ever you like. For those more familiar with Linux, you can use the çrontab -e’ command and add the two lines presented here at the end of file. Below, I am presenting an alternative method to add the lines in the ‘crontab’ file of user ‘root’. When you add lines to the ‘root’ crontab file in this matter, you must inform the ‘cron’ daemon that it need to reload its configuration file, so it is aware of the changes we made. Both of these method, will schedule our script at the chosen time.
# echo '# Backup important directories to DVD' >> /var/spool/cron/root # echo '0 3 * * 1,3,5 /linternux/bin/dvd_backup.sh >/dev/null 2>&1' >> /var/spool/cron/root # service crond reload Reloading cron daemon configuration: [ OK ] #
Once downloaded the dvd_backup.sh script, need to modify it to fit your need.
- ‘BASEDIR‘ variable need to be change to represent the location of the ‘log’ directory. This can easily be change to ‘BASEDIR=”/var”‘. This is where the log file of the script is created. This is the file that will be email to you.
- “DVD_DEV” indicate the device representing your DVD writer. Usually, it should be set to ‘/dev/cdrom’, ‘dev/hdd’ or ‘/dev/dvd’.
- “SYSADMIN” variable represent the email address you would like the log file to be sent.
- “BACKDIR” is the variable where you specify each and every directories you wish to include on the DVD backup. The syntax may seems redundant, but this is the way we need to specify them. We need to specify the name of the directory twice, separated by and equal sign.

Part that is subject to change
The rest of the script does not need to be changed, but is presented here for information purpose only. The script require a DVD+RW, the DVD-RW will not work with this script. The script use the “dvd+rw-format” and the “growisofs” command to format and write to the DVD. If an error occurs, during the format or the backup, an email is sent to the system administrator and the process is stopped.

Part of the script that doesn't need to be change
If you want to know more about using dvd+rw , see the “Burning DVD+RW in Linux” web page.
The script dvd_backup.sh is free to use, have fun and see you soon !

Thanks for posting this… it was exactly what I needed!