Document version: Fri Dec 31 23:59:59 UTC 2008
This article was written in April 2006 by Gene Alexander of ERA Computers & Consulting.
The example quick and dirty commands for the impatient
/usr/bin/growisofs -Z /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V Backup\
root=/root
/usr/bin/growisofs -M /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V Backup\
etc/mail=/etc/mail\
var/ftp/downloads=/var/ftp/downloads
Target Audience
The target audience for this article includes any person needing to create backups of data on a regular basis within an operating system that can run growisofs from dvd+rw-tools. Typically the operating system will be a Unix (BSD, AIX, SCO, etcetera) or Linux distribution or derivative. The person need not be a techno-geek to be able to use this information but an understanding that there is a command line and how to access it is assumed. In the section covering running growisofs under cron jobs one will (usually) need to be able to use vi or vim and have an understanding of creating cron jobs. To be able to backup files requiring privileged access one will need to be able to either run growisofs as 'root' or with sudo or an equivalent. Teaching how one does these things is beyond the scope of this document.
Synopsis
One may not have or be able to afford a $600.00/US (or more) tape drive to do reliable backups of 8GB, 4GB or less of data. However many Home, SOHO and SMB desktop and server PCs come with a DVD±RW drive installed. If not then an IDE or SATA DVD±RW drive can be purchased for well under $100.00/US (the author has seen them for as little as $49.00/US and less). Current drives have the ability to store roughly 8GB of data using double density DVD media. These drives are relatively inexpensive and so is DVD+RW media. For “permanent” storage one may use DVD+R media which cannot be overwritten.
The command again with explanations following
/usr/bin/growisofs -Z /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V Backup\
root=/root
/usr/bin/growisofs -M /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V Backup\
etc/mail=/etc/mail\
var/ftp/downloads=/var/ftp/downloads
Under bash/sh shells the “\<lf>” is a continuation combination which basically tells the shell “there is more on the next line, keep reading”.
Some information about the above command:
- If one is using a relatively new DVD±RW drive with DVD+R(W) media then one may need to acquire the latest release of dvd+rw-tools to have growisofs work properly with the drive. One may acquire the latest release here (as of April 2006): http://fy.chalmers.se/~appro/linux/DVD+RW/
- On any one system the '/dev/dvd' may be something else so it is up to the end-user to figure out which device in '/dev' is the DVD±RW drive.
- The first command will format new discs and create a small file system on the DVD+RW media. It will fail on discs that are already formatted and contain data. This is not a problem and may be safely ignored. One may replace the root=/root with whatever small data set one may require.
- The '-D' switch passed to mkisofs from growisofs comes with this warning in the mkisofs man page, “If ISO9660:1999 has not been selected, this violates the ISO9660 standard, but it happens to work on many systems. Use with caution.”
- The '-graft-points' switch is connected to the 'etc/mail=/etc/mail' and 'var/ftp/downloads=/var/ftp/downloads' section. It basically says build the directory 'etc/mail' on the DVD media root directory and put the files from '/etc/mail' on the hard drive in the created directory on the DVD media. The same goes for the 'var/ftp...' section. Add any directories and their corresponding graft points in the bottom section of the command.
- To backup your web site in '/var/www/*' use – var/www=/var/www
- To backup your user home directories use – home=/home
- The '-iso-level 4' switch passed to mkisofs from growisofs comes with this warning in the mkisofs man page, “Level 4 officially does not exists but mkisofs maps it to ISO-9660:1999 which is ISO-9660 version 2.”
- For full explanations of the switches please see the growisofs man page and the mkisofs man page. If one is a "newbie" to Unix/Linux then learning to read and understand man pages is an excellent exercise.
Setting up a cron job for automating backups with growisofs
To become the user needing to create backups (typically root) one must open a terminal window (if in X) or switch to a console command line session (if in X). Then use 'su – root' or login 'root' and type in the root password to become root. Copy and edit the following for a bash script. Save it as "mydvdbackup" or whatever one wants:
#!/bin/bash
# Replace the following with actual locations on *your* system
GROWISOFS=/usr/bin/growisofs
ECHO=/bin/echo
SLEEP=/bin/sleep
GREP=/bin/grep
MAIL=/bin/mail
today=`/bin/date +%A`
# Backup begins below
$ECHO "Beginning $today backup to DVD" > /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Format and create a small iso set on DVD in case this is a new disc" >> /tmp/backupoutput.tmp
$ECHO "(the following may fail if disc already has data on it, no problem)" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$GROWISOFS -Z /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V "$today Backup"\
root=/root >> /tmp/backupoutput.tmp 2>&1
mycode=$?
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Return code from above is: $mycode" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Waiting 30 seconds then continuing" >> /tmp/backupoutput.tmp
$SLEEP 30
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Now creating actual $today backup" >> /tmp/backupoutput.tmp
$ECHO "(should not fail at this point)" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$GROWISOFS -M /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V "$today Backup"\
etc/mail=/etc/mail\
etc/firewall=/etc/firewall\
home=/home\
root=/root >> /tmp/backupoutput.tmp 2>&1
# Modify graft points above as needed
mycode=$?
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Return code from above is: $mycode" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$ECHO "End of $today backup" >> /tmp/backupoutput.tmp
$GREP -i -v sleeping /tmp/backupoutput.tmp > /tmp/backupoutput.tmp2
$GREP -i -v formatting /tmp/backupoutput.tmp2 > /tmp/backupoutput.txt
$MAIL -n -s "Output from DVD backup" usermail@domain < /tmp/backupoutput.txt
If one is root the file will be created in the home directory for root. Then make mydvdbackup executable with 'chmod 700 mydvdbackup'. Then type 'crontab -e' to edit the crontab file for cron jobs run as root. To run the command unattended at 0300 (3:00AM) every day type in something similar to the following:
0 3 * * * /path/to/mydvdbackup
For example:
0 3 * * * /root/bin/mydvdbackup
After "mv"ing the script to /root/bin.
Then save and exit the crontab editor. Place DVD rewritable media in the drive and check it the following day to verify your backup worked. Do not forget to create a rotation schedule of your media to have multiple fallback points when you need them after a crash, compromise or other event.
Addendum 2006.11.13
The commands in the script shown previously will eventually fill the DVD disc with appended data. The way to solve this problem is with the undocumented switch "-use-the-force-luke=tty" which turns off the check for an interactive shell. This will allow the non-interactive use of the "-Z" switch for "blanking" with the command:
growisofs -use-the-force-luke=tty -Z /dev/dvd=/dev/zero
Which may be used on a media that already has a file system. Without this undocumented switch use of "-Z" non-interactively in a cronjob will cause a fatal failure.
One may decide to rewrite the previous script with this switch added along with one other. Here is how that would look:
#!/bin/bash
# Replace the following with actual locations on *your* system
GROWISOFS=/usr/bin/growisofs
ECHO=/bin/echo
GREP=/bin/grep
MAIL=/bin/mail
today=`/bin/date +%A`
# Backup begins below
$ECHO "Creating $today backup" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$GROWISOFS -use-the-force-luke=tty -dvd-compat -M /dev/dvd -D -J -R -T -l\
-graft-points -joliet-long -hide-joliet-trans-tbl\
-iso-level 4 -speed=1 -overburn -V "$today Backup"\
etc/mail=/etc/mail\
etc/firewall=/etc/firewall\
home=/home\
root=/root >> /tmp/backupoutput.tmp 2>&1
# Modify graft points above as needed
mycode=$?
$ECHO >> /tmp/backupoutput.tmp
$ECHO "Return code from above is: $mycode" >> /tmp/backupoutput.tmp
$ECHO >> /tmp/backupoutput.tmp
$ECHO "End of $today backup" >> /tmp/backupoutput.tmp
$GREP -i -v sleeping /tmp/backupoutput.tmp > /tmp/backupoutput.tmp2
$GREP -i -v formatting /tmp/backupoutput.tmp2 > /tmp/backupoutput.txt
$MAIL -n -s "Output from DVD backup" usermail@domain < /tmp/backupoutput.txt
Addendum 2008.12.31
Here is another tweak to backup to DVD+RW media. This version uses 'tar' to create a gzipped tar file of the data to be backed up then runs the commands to create or overwrite a DVD+RW disc with the tar file. First the tar file creation script:
/bin/tar zcvf /data/tarbackup.tar.gz \
/etc/mail \
/etc/firewall \
/etc/sysconfig/clamav-milter \
/home/sales \
/home/service \
/root \
/var/lib/clamav \
/var/named \
/var/spool/mail \
/var/www \
/etc/aliases \
/etc/clamd.conf \
/etc/dspam.conf \
/etc/group \
/etc/gshadow \
/etc/hosts \
/etc/named.conf \
/etc/passwd \
/etc/resolv.conf \
/etc/shadow >> /tmp/taroutput.tmp 2>&1
This file should be created on a partition that is large enough to hold up to the largest size the file could become on one's system. Following is the new script for backup to DVD:
#!/bin/bash
today=`/bin/date +%A`
/bin/echo "Beginning $today backup to DVD" > /tmp/backupoutput.tmp
/bin/echo >> /tmp/backupoutput.tmp
/bin/echo "Creating $today backup" >> /tmp/backupoutput.tmp
/bin/echo "(using undocumented switch -use-the-force-luke=tty to allow non-interactive overwrite)" >> /tmp/backupoutput.tmp
/bin/echo >> /tmp/backupoutput.tmp
/usr/bin/growisofs -use-the-force-luke=tty -dvd-compat -Z \
/dev/dvd -D -J -R -T -l \
-graft-points -joliet-long -hide-joliet-trans-tbl \
-iso-level 4 -speed=1 -overburn -V "$today Backup" \
tarbackup.tar.gz=/data/tarbackup.tar.gz >> /tmp/backupoutput.tmp 2>&1
mycode=$?
/bin/echo >> /tmp/backupoutput.tmp
/bin/echo "Return code from above is: $mycode" >> /tmp/backupoutput.tmp
/bin/echo >> /tmp/backupoutput.tmp
/bin/echo "End of $today backup" >> /tmp/backupoutput.tmp
/bin/grep -i -v sleeping /tmp/backupoutput.tmp > /tmp/backupoutput.tmp2
/bin/grep -i -v formatting /tmp/backupoutput.tmp2 > /tmp/backupoutput.txt
/bin/mail -n -s "Output from DVD backup" -c user@domain </tmp/backupoutput.txt
The cronfile line for this should look similar to the following:
30 23 * * 1-5 /root/bin/tarbackup && /root/bin/dvdbackup
This document should now cover just about anyone's needs for backup to DVD+RW media using growisofs. Please feel free to make your own suggestions by adding a comment to this page.
The information in this document should allow anyone with a modicum of intellect to be able to figure out how to create backups and sets of backups to DVD media. If after reading this document one is confused about what to do then the author respectfully suggests hiring a good consultant to read this document and get one's backups working. The author would like to point out he is a good consultant ...
If you find any of the documents on our information pages useful please make a secure donation to help us defray the cost of our bandwidth to provide these documents. Thank you.

