Subsections


DVD Volumes

Bacula allows you to specify that you want to write to DVD. However, this feature is implemented only in version 1.37 or later. You may in fact write to DVD+RW, DVD+R, DVD-R, or DVD-RW media. The actual process used by Bacula is to first write the image to a spool directory, then when the Volume reaches a certain size or, at your option, at the end of a Job, Bacula will transfer the image from the spool directory to the DVD. The actual work of transferring the image is done by a script dvd-handler, and the heart of that script is a program called growisofs which allows creating or adding to a DVD ISO filesystem.

You must have dvd+rw-tools loaded on your system for DVD writing to work. Please note that the original dvd+rw-tools package does NOT work with Bacula. You must apply a patch which can be found in the patches directory of Bacula sources with the name dvd+rw-tools-5.21.4.10.8.bacula.patch for version 5.21 of the tools, or patch bf dvd+rw-tools-6.1.bacula.patch if you have version 6.1 on your system. Unfortunately, this requires you to build the dvd_rw-tools from source.

Note, some Linux distros such as Debian dvd+rw-tools-7.0-4 package already have the patch applied, so please check.

The fact that Bacula cannot use the OS to write directly to the DVD makes the whole process a bit more error prone than writing to a disk or a tape, but nevertheless, it does work if you use some care to set it up properly. However, at the current time (version 1.39.30 -- 12 December 2006) we still consider this code to be BETA quality. As a consequence, please do careful testing before relying on DVD backups in production.

The remainder of this chapter explains the various directives that you can use to control the DVD writing.

DVD Specific SD Directives

The following directives are added to the Storage daemon's Device resource.

Requires Mount = Yes|No
You must set this directive to yes for DVD-writers, and to no for all other devices (tapes/files). This directive indicates if the device requires to be mounted using the Mount Command. To be able to write a DVD, the following directives must also be defined: Mount Point, Mount Command, Unmount Command and Write Part Command.

Mount Point = directory
Directory where the device can be mounted.

Mount Command = name-string
Command that must be executed to mount the device. Although the device is written directly, the mount command is necessary in order to determine the free space left on the DVD. Before the command is executed, %a is replaced with the Archive Device, and %m with the Mount Point.

Most frequently, you will define it as follows:

  Mount Command = "/bin/mount -t iso9660 -o ro %a %m"

However, if you have defined a mount point in /etc/fstab, you might be able to use a mount command such as:

  Mount Command = "/bin/mount /media/dvd"

Unmount Command = name-string
Command that must be executed to unmount the device. Before the command is executed, %a is replaced with the Archive Device, and %m with the Mount Point.

Most frequently, you will define it as follows:

  Unmount Command = "/bin/umount %m"

Write Part Command = name-string
Command that must be executed to write a part to the device. Before the command is executed, %a is replaced with the Archive Device, %m with the Mount Point, %e is replaced with 1 if we are writing the first part, and with 0 otherwise, and %v with the current part filename.

For a DVD, you will most frequently specify the Bacula supplied dvd-handler script as follows:

  Write Part Command = "/path/dvd-handler %a write %e %v"

Where /path is the path to your scripts install directory, and dvd-handler is the Bacula supplied script file. This command will already be present, but commented out, in the default bacula-sd.conf file. To use it, simply remove the comment (#) symbol.

Free Space Command = name-string
Command that must be executed to check how much free space is left on the device. Before the command is executed,%a is replaced with the Archive Device.

For a DVD, you will most frequently specify the Bacula supplied dvd-handler script as follows:

  Free Space Command = "/path/dvd-handler %a free"

Where /path is the path to your scripts install directory, and dvd-freespace is the Bacula supplied script file. If you want to specify your own command, please look at the code in dvd-handler to see what output Bacula expects from this command. This command will already be present, but commented out, in the default bacula-sd.conf file. To use it, simply remove the comment (#) symbol.

If you do not set it, Bacula will expect there is always free space on the device.

In addition to the directives specified above, you must also specify the other standard Device resource directives. Please see the sample DVD Device resource in the default bacula-sd.conf file. Be sure to specify the raw device name for Archive Device. It should be a name such as /dev/cdrom or /media/cdrecorder or /dev/dvd depending on your system. It will not be a name such as /mnt/cdrom.

Finally, for growisofs to work, it must be able to lock a certain amount of memory in RAM. If you have restrictions on this function, you may have failures. Under bash, you can set this with the following command:

ulimit -l unlimited

Edit Codes for DVD Directives

Before submitting the Mount Command, Unmount Command, Write Part Command, or Free Space Command directives to the operating system, Bacula performs character substitution of the following characters:

    %% = %
    %a = Archive device name
    %e = erase (set if cannot mount and first part)
    %n = part number
    %m = mount point
    %v = last part name (i.e. filename)

DVD Specific Director Directives

The following directives are added to the Director's Job resource.

Write Part After Job = <yes|no>
If this directive is set to yes (default no), the Volume written to a temporary spool file for the current Job will be written to the DVD as a new part file will be created after the job is finished.

It should be set to yes when writing to devices that require a mount (for example DVD), so you are sure that the current part, containing this job's data, is written to the device, and that no data is left in the temporary file on the hard disk. However, on some media, like DVD+R and DVD-R, a lot of space (about 10Mb) is lost everytime a part is written. So, if you run several jobs each after another, you could set this directive to no for all jobs, except the last one, to avoid wasting too much space, but to ensure that the data is written to the medium when all jobs are finished.

This directive is ignored for devices other than DVDs.

Other Points

Kern Sibbald 2009-02-06