1%%
2%%
3
4\chapter{DVD Volumes}
5\label{_DVDChapterStart}
6\index[general]{DVD Volumes}
7\index[general]{Writing DVDs}
8\index[general]{DVD Writing}
9\index[general]{Volumes!DVD}
10
11Bacula allows you to specify that you want to write to DVD. However,
12this feature is implemented only in version 1.37 or later.
13You may in fact write to DVD+RW, DVD+R, DVD-R, or DVD-RW
14media. The actual process used by Bacula is to first write
15the image to a spool directory, then when the Volume reaches
16a certain size or,  at your option, at the end of a Job, Bacula
17will transfer the image from the spool directory to the
18DVD.  The actual work of transferring the image is done
19by a script {\bf dvd-handler}, and the heart of that
20script is a program called {\bf growisofs} which allows
21creating or adding to a DVD ISO filesystem.
22
23You must have {\bf dvd+rw-tools} loaded on your system for DVD writing to
24work.  Please note that the original {\bf dvd+rw-tools} package does {\bf
25NOT} work with Bacula.  You must apply a patch which can be found in the
26{\bf patches} directory of Bacula sources with the name
27{\bf dvd+rw-tools-5.21.4.10.8.bacula.patch} for version 5.21 of the tools,
28or patch {bf dvd+rw-tools-6.1.bacula.patch} if you have version 6.1
29on your system. Unfortunately, this requires you to build the dvd\_rw-tools
30from source.
31
32Note, some Linux distros such as Debian dvd+rw-tools-7.0-4 package already
33have the patch applied, so please check.
34
35The fact that Bacula cannot use the OS to write directly
36to the DVD makes the whole process a bit more error prone than
37writing to a disk or a tape, but nevertheless, it does work if you
38use some care to set it up properly. However, at the current time
39(version 1.39.30 -- 12 December 2006) we still consider this code to be
40BETA quality.  As a consequence, please do careful testing before relying
41on DVD backups in production.
42
43The remainder of this chapter explains the various directives that you can
44use to control the DVD writing.
45
46\label{DVDdirectives}
47\section{DVD Specific SD Directives}
48\index[general]{Directives!DVD}
49\index[general]{DVD Specific SD Directives }
50
51The following directives are added to the Storage daemon's
52Device resource.
53
54\begin{description}
55
56\item [Requires Mount = {\it Yes|No}]
57   \index[general]{Requires Mount  }
58   You must set this directive to {\bf yes} for DVD-writers,  and to {\bf no} for
59   all other devices (tapes/files).  This directive indicates if the device
60   requires to be mounted using the {\bf Mount Command}.
61   To be able to write a DVD, the following directives must also be
62   defined: {\bf Mount Point},  {\bf Mount Command}, {\bf Unmount Command} and
63   {\bf Write Part Command}.
64
65\item [Mount Point = {\it directory}]
66   \index[general]{Mount Point}
67   Directory where the device can be mounted.
68
69\item [Mount Command = {\it name-string}]
70   \index[general]{Mount Command}
71   Command that must be executed to mount the device. Although the
72   device is written directly, the mount command is necessary in
73   order to determine the free space left on the DVD. Before the command is
74   executed, \%a is replaced with the Archive Device, and \%m with the Mount
75   Point.
76
77   Most frequently, you will define it as follows:
78
79\footnotesize
80\begin{verbatim}
81  Mount Command = "/bin/mount -t iso9660 -o ro %a %m"
82\end{verbatim}
83\normalsize
84
85However, if you have defined a mount point in /etc/fstab, you might be
86able to use a mount command such as:
87
88\footnotesize
89\begin{verbatim}
90  Mount Command = "/bin/mount /media/dvd"
91\end{verbatim}
92\normalsize
93
94
95\item [Unmount Command = {\it name-string}]
96   \index[general]{Unmount Command}
97   Command that must be executed to unmount the device. Before the command  is
98   executed, \%a is replaced with the Archive Device, and \%m with the  Mount
99   Point.
100
101   Most frequently, you will define it as follows:
102
103\footnotesize
104\begin{verbatim}
105  Unmount Command = "/bin/umount %m"
106\end{verbatim}
107\normalsize
108
109\item [Write Part Command = {\it name-string}]
110   \index[general]{Write Part Command  }
111   Command that must be executed to write a part to the device. Before the
112   command is executed, \%a is replaced with the Archive Device, \%m with the
113   Mount Point, \%e is replaced with 1 if we are writing the first part,
114   and with 0 otherwise, and \%v with the current part filename.
115
116   For a DVD, you will most frequently specify the Bacula supplied  {\bf
117   dvd-handler} script as follows:
118
119\footnotesize
120\begin{verbatim}
121  Write Part Command = "/path/dvd-handler %a write %e %v"
122\end{verbatim}
123\normalsize
124
125  Where {\bf /path} is the path to your scripts install directory, and
126  dvd-handler is the Bacula supplied script file.
127  This command will already be present, but commented out,
128  in the default bacula-sd.conf file. To use it, simply remove
129  the comment (\#) symbol.
130
131
132\item [Free Space Command = {\it name-string}]
133   \index[general]{Free Space Command  }
134   Command that must be executed to check how much free space is left on the
135   device. Before the command is executed,\%a is replaced with the Archive
136   Device.
137
138   For a DVD, you will most frequently specify the Bacula supplied  {\bf
139   dvd-handler} script as follows:
140
141\footnotesize
142\begin{verbatim}
143  Free Space Command = "/path/dvd-handler %a free"
144\end{verbatim}
145\normalsize
146
147  Where {\bf /path} is the path to your scripts install directory, and
148  dvd-handler is the Bacula supplied script file.
149  If you want to specify your own command, please look at the code in
150  dvd-handler to see what output Bacula expects from this command.
151  This command will already be present, but commented out,
152  in the default bacula-sd.conf file. To use it, simply remove
153  the comment (\#) symbol.
154
155  If you do not set it, Bacula will expect there is always free space on the
156  device.
157
158\end{description}
159
160In addition to the directives specified above, you must also
161specify the other standard Device resource directives. Please see the
162sample DVD Device resource in the default bacula-sd.conf file. Be sure
163to specify the raw device name for {\bf Archive Device}. It should
164be a name such as {\bf /dev/cdrom} or {\bf /media/cdrecorder} or
165{\bf /dev/dvd} depending on your system.  It will not be a name such
166as {\bf /mnt/cdrom}.
167
168Finally, for {\bf growisofs} to work, it must be able to lock
169a certain amount of memory in RAM.  If you have restrictions on
170this function, you may have failures.  Under {\bf bash}, you can
171set this with the following command:
172
173\footnotesize
174\begin{verbatim}
175ulimit -l unlimited
176\end{verbatim}
177\normalsize
178
179\section{Edit Codes for DVD Directives}
180\index[general]{Directives!DVD Edit Codes}
181\index[general]{Edit Codes for DVD Directives }
182
183Before submitting the {\bf Mount Command}, {\bf Unmount Command},
184{\bf Write Part Command}, or {\bf Free Space Command} directives
185to the operating system, Bacula performs character substitution of the
186following characters:
187
188\footnotesize
189\begin{verbatim}
190    %% = %
191    %a = Archive device name
192    %e = erase (set if cannot mount and first part)
193    %n = part number
194    %m = mount point
195    %v = last part name (i.e. filename)
196\end{verbatim}
197\normalsize
198
199
200
201\section{DVD Specific Director Directives}
202\index[general]{Directives!DVD}
203\index[general]{DVD Specific Director Directives }
204
205The following directives are added to the Director's Job resource.
206
207\label{WritePartAfterJob}
208\begin{description}
209\item [Write Part After Job = \lt{}yes|no\gt{}]
210   \index[general]{Write Part After Job }
211   If this directive is set to {\bf yes} (default {\bf no}), the
212   Volume written to a temporary spool file for the current Job will
213   be written to the DVD as a new part file
214   will be created after the job is finished.
215
216   It should be set to {\bf yes} when writing to devices that require a mount
217   (for example DVD), so you are sure that the current part, containing
218   this job's data, is written to the device, and that no data is left in
219   the temporary file on the hard disk.  However, on some media, like DVD+R
220   and DVD-R, a lot of space (about 10Mb) is lost everytime a part is
221   written.  So, if you run several jobs each after another, you could set
222   this directive to {\bf no} for all jobs, except the last one, to avoid
223   wasting too much space, but to ensure that the data is written to the
224   medium when all jobs are finished.
225
226   This directive is ignored for devices other than DVDs.
227\end{description}
228
229
230
231\label{DVDpoints}
232\section{Other Points}
233\index[general]{Points!Other }
234\index[general]{Other Points }
235
236\begin{itemize}
237\item Please be sure that you have any automatic DVD mounting
238   disabled before running Bacula -- this includes auto mounting
239   in /etc/fstab, hotplug, ...  If the DVD is automatically
240   mounted by the OS, it will cause problems when Bacula tries
241   to mount/unmount the DVD.
242\item Please be sure that you the directive {\bf Write Part After Job}
243   set to {\bf yes}, otherwise the last part of the data to be
244   written will be left in the DVD spool file and not written to
245   the DVD. The DVD will then be unreadable until this last part
246   is written.  If you have a series of jobs that are run one at
247   a time, you can turn this off until the last job is run.
248\item The current code is not designed to have multiple simultaneous
249   jobs writing to the DVD.  As a consequence, please ensure that
250   only one DVD backup job runs at any time.
251\item Writing and reading of DVD+RW seems to work quite reliably
252   provided you are using the patched dvd+rw-mediainfo programs.
253   On the other hand, we do not have enough information to ensure
254   that DVD-RW or other forms of DVDs work correctly.
255\item DVD+RW supports only about 1000 overwrites. Every time you
256   mount the filesystem read/write will count as one write. This can
257   add up quickly, so it is best to mount your DVD+RW filesystem read-only.
258   Bacula does not need the DVD to be mounted read-write, since it uses
259   the raw device for writing.
260\item Reformatting DVD+RW 10-20 times can apparently make the medium
261   unusable. Normally you should not have to format or reformat
262   DVD+RW media. If it is necessary, current versions of growisofs will
263   do so automatically.
264\item We have had several problems writing to DVD-RWs (this does NOT
265  concern DVD+RW), because these media have two writing-modes: {\bf
266  Incremental Sequential} and {\bf Restricted Overwrite}.  Depending on
267  your device and the media you use, one of these modes may not work
268  correctly (e.g.  {\bf Incremental Sequential} does not work with my NEC
269  DVD-writer and Verbatim DVD-RW).
270
271  To retrieve the current mode of a DVD-RW, run:
272\begin{verbatim}
273  dvd+rw-mediainfo /dev/xxx
274\end{verbatim}
275  where you replace xxx with your DVD device name.
276
277  {\bf Mounted Media} line should give you the information.
278
279  To set the device to {\bf Restricted Overwrite} mode, run:
280\begin{verbatim}
281  dvd+rw-format /dev/xxx
282\end{verbatim}
283  If you want to set it back to the default {\bf Incremental Sequential} mode, run:
284\begin{verbatim}
285  dvd+rw-format -blank /dev/xxx
286\end{verbatim}
287
288\item Bacula only accepts to write to blank DVDs. To quickly blank a DVD+/-RW, run
289  this command:
290\begin{verbatim}
291  dd if=/dev/zero bs=1024 count=512 | growisofs -Z /dev/xxx=/dev/fd/0
292\end{verbatim}
293  Then, try to mount the device, if it cannot be mounted, it will be considered
294  as blank by Bacula, if it can be mounted, try a full blank (see below).
295
296\item If you wish to blank completely a DVD+/-RW, use the following:
297\begin{verbatim}
298  growisofs -Z /dev/xxx=/dev/zero
299\end{verbatim}
300  where you replace xxx with your DVD device name. However, note that this
301  blanks the whole DVD, which takes quite a long time (16 minutes on mine).
302\item DVD+RW and DVD-RW support only about 1000 overwrites (i.e. don't use the
303same medium for years if you don't want to have problems...).
304
305To write to the DVD the first time use:
306\begin{verbatim}
307  growisofs -Z /dev/xxx filename
308\end{verbatim}
309
310To add additional files (more parts use):
311
312\begin{verbatim}
313  growisofs -M /dev/xxx filename
314\end{verbatim}
315
316The option {\bf -use-the-force-luke=4gms} was added in growisofs 5.20 to
317override growisofs' behavior of always checking for the 4GB limit.
318Normally, this option is recommended for all Linux 2.6.8 kernels or
319greater, since these newer kernels can handle writing more than 4GB.
320See below for more details on this subject.
321
322\item For more information about DVD writing, please look at the
323\elink{dvd+rw-tools homepage}{http://fy.chalmers.se/~appro/linux/DVD+RW/}.
324
325\item According to bug \#912, bscan cannot read multi-volume DVDs.  This is
326on our TODO list, but unless someone submits a patch it is not likely to be
327done any time in the near future. (9 Sept 2007).
328
329\end{itemize}
330