Multi session dvd using cdrecord

I wrote the following script after reading a tutorial, but...

#!/usr/bin/ksh                                      
DATE=`date +"%y%m%d%H%M"`                           
echo $DATE                                          
FILENAME=`echo "obase = 16\n $DATE"|bc`             
echo $FILENAME                                      
cd /                                                
tar ctvf /home/$FILENAME.tar u >/dev/null           
cd /home                                            
gzip $FILENAME.tar                                  
mv $FILENAME.tar.gz $FILENAME.tgz                   
POSITION=`cdrecord -msinfo`                         
echo $POSITION                                      
mkisofs -o $FILENAME.iso -C $POSITION $FILENAME.tgz 
cdrecord -sao -multi $FILENAME.iso       

but when I run

cdrecord -msinfo

afterwards, it always says 0,0
The media is DVD-RW
What I had hoped would happen is that the latest backup would be appended to the dvd.

Check the contents of the DVD, not just its session IDs, does it have the extra files or not?

---------- Post updated at 11:52 AM ---------- Previous update was at 11:41 AM ----------

You should add -R and -J to your mkisofs options, otherwise you'll be restricted to 8.3 style filenames.

From man cdrecord:

       -multi Allow  multi  session CDs or multi border DVDs to be made.  This
              flag needs to be present on all sessions of a multi  session  or
              multi  border  disk, except you want to create a session on a CD
              that will be the last session on the CD media.

              For CD media, the fixation will be done in a way that allows the
              CD/DVD/BluRay-Recorder to append additional sessions later. This
              is done by generation a TOC with a  link  to  the  next  program
              area.  The so generated media is not 100% compatible to manufac-
              tured CDs (except for CDplus).  Use only for recording of  multi
              session  CDs.  If this option is present, the default track type
              is CD-ROM XA mode 2 form 1 and the sector size  is  2048  bytes.
              The XA sector subheaders will be created by the drive.  The Sony
              drives have no hardware support for CD-ROM XA  mode  2  form  1.
              You  have  to  specify the -data option in order to create multi
              session disks on these drives.  If you like to record  a  multi-
              session  disk  in  SAO mode, you need to force CD-ROM sectors by
              including the -data option.  Not all drives  allow  multisession
              CDs in SAO mode.

              For  DVD  media,  -multi  switches the write mode to incremental
              packet recording.  There is currently  no  way  to  prevent  the
              ability  to  append further sessions and there is currently only
              support for DVD-R/DVD-RW media.  To reuse a DVD-RW that has pre-
              viously  been  written  in incremental packet recording mode for
              different write modes,  you  need  to  blank  the  entire  media
              before.

So multisession doesn't work the same way with DVD's, and 'session info' may not be valid.

Why not use growisofs? It's sort of a combined cdrecord and mkisofs built specially for multisession DVD's, not CD's.

# Burn the first session
growisofs -Z /dev/dvd -R -J backup1.tar.gz
# Burn on another session
growisofs -M /dev/dvd -R -J backup2.tar.gz

Something to be aware of when using mkisofs and growisofs is when you do mkisofs ... folder1 folder2 it adds folder1/file.txt and folder2/file.txt to the base folder, not as folder1/file.txt and folder2/file.txt. This will try to create two files with the same name, causing mkisofs to die with a mysterious error about duplicate filenames which took me much headscratching to figure out.