]> git.sur5r.net Git - bacula/docs/blob - docs/manual/recycling.tex
Update FOSDEM talk
[bacula/docs] / docs / manual / recycling.tex
1 %%
2 %%
3
4 \chapter{Automatic Volume Recycling}
5 \label{RecyclingChapter}
6 \index[general]{Recycling!Automatic Volume }
7 \index[general]{Automatic Volume Recycling }
8
9 By default, once Bacula starts writing a Volume, it can append to the
10 volume, but it will not overwrite the existing data thus destroying it.
11 However when Bacula {\bf recycles} a Volume, the Volume becomes available
12 for being reused, and Bacula can at some later time overwrite the previous
13 contents of that Volume.  Thus all previous data will be lost.  If the
14 Volume is a tape, the tape will be rewritten from the beginning.  If the
15 Volume is a disk file, the file will be truncated before being rewritten.
16
17 You may not want Bacula to automatically recycle (reuse) tapes.  This would
18 require a large number of tapes though, and in such a case, it is possible
19 to manually recycle tapes.  For more on manual recycling, see the section
20 entitled \ilink{ Manually Recycling Volumes}{manualrecycling} below in this
21 chapter.
22
23 Most people prefer to have a Pool of tapes that are used for daily backups and
24 recycled once a week, another Pool of tapes that are used for Full backups
25 once a week and recycled monthly, and finally a Pool of tapes that are used
26 once a month and recycled after a year or two. With a scheme like this, the 
27 number of tapes in your pool or pools remains constant.
28
29 By properly defining your Volume Pools with appropriate Retention periods,
30 Bacula can manage the recycling (such as defined above) automatically. 
31
32 Automatic recycling of Volumes is controlled by three records in the {\bf
33 Pool} resource definition in the Director's configuration file. These three
34 records are: 
35
36 \begin{itemize}
37 \item AutoPrune = yes 
38 \item VolumeRetention = \lt{}time\gt{} 
39 \item Recycle = yes 
40 \end{itemize}
41
42 The above three directives are all you need assuming that you fill
43 each of your Volumes then wait the Volume Retention period before 
44 reusing them.  If you want Bacula to stop using a Volume and recycle
45 it before it is full, you will need to use one or more additional 
46 directives such as:
47 \begin{itemize}
48 \item Use Volume Once = yes
49 \item Volume Use Duration = ttt
50 \item Maximum Volume Jobs = nnn
51 \item Maximum Volume Bytes = mmm
52 \end{itemize}
53 Please see below and 
54 the \ilink{Basic Volume Management}{DiskChapter} chapter
55 of this manual for more complete examples.  
56
57 Automatic recycling of Volumes is performed by Bacula only when it wants a
58 new Volume and no appendable Volumes are available in the Pool. It will then
59 search the Pool for any Volumes with the {\bf Recycle} flag set and whose
60 Volume Status is {\bf Full}. At that point, the recycling occurs in two steps.
61 The first is that the Catalog for a Volume must be purged of all Jobs and
62 Files contained on that Volume, and the second step is the actual recycling of
63 the Volume. The Volume will be purged if the VolumeRetention period has
64 expired. When a Volume is marked as Purged, it means that no Catalog records
65 reference that Volume, and the Volume can be recycled. Until recycling
66 actually occurs, the Volume data remains intact. If no Volumes can be found
67 for recycling for any of the reasons stated above, Bacula will request
68 operator intervention (i.e. it will ask you to label a new volume). 
69
70 A key point mentioned above, that can be a source of frustration, is that Bacula
71 will only recycle purged Volumes if there is no other appendable Volume
72 available, otherwise, it will always write to an appendable Volume before
73 recycling even if there are Volume marked as Purged. This preserves your data
74 as long as possible. So, if you wish to "force" Bacula to use a purged
75 Volume, you must first ensure that no other Volume in the Pool is marked {\bf
76 Append}. If necessary, you can manually set a volume to {\bf Full}. The reason
77 for this is that Bacula wants to preserve the data on your old tapes (even
78 though purged from the catalog) as long as absolutely possible before
79 overwriting it. There are also a number of directives such as
80 {\bf Volume Use Duration} that will automatically mark a volume as {\bf
81 Used} and thus no longer appendable.
82
83 \label{AutoPruning}
84 \section{Automatic Pruning}
85 \index[general]{Automatic Pruning}
86 \index[general]{Pruning!Automatic}
87
88 As Bacula writes files to tape, it keeps a list of files, jobs, and volumes
89 in a database called the catalog.  Among other things, the database helps
90 Bacula to decide which files to back up in an incremental or differential
91 backup, and helps you locate files on past backups when you want to restore
92 something.  However, the catalog will grow larger and larger as time goes
93 on, and eventually it can become unacceptably large.
94
95 Bacula's process for removing entries from the catalog is called Pruning.
96 The default is Automatic Pruning, which means that once an entry reaches a
97 certain age (e.g.  30 days old) it is removed from the catalog.  Once a job
98 has been pruned, you can still restore it from the backup tape, but one
99 additional step is required: scanning the volume with bscan.  The
100 alternative to Automatic Pruning is Manual Pruning, in which you explicitly
101 tell Bacula to erase the catalog entries for a volume.  You'd usually do
102 this when you want to reuse a Bacula volume, because there's no point in
103 keeping a list of files that USED TO BE on a tape.  Or, if the catalog is
104 starting to get too big, you could prune the oldest jobs to save space.
105 Manual pruning is done with the \ilink{ prune command}{ManualPruning} in
106 the console.  (thanks to Bryce Denney for the above explanation).
107
108 \section{Pruning Directives}
109 \index[general]{Pruning Directives }
110 \index[general]{Directives!Pruning }
111
112 There are three pruning durations. All apply to catalog database records and
113 not to the actual data in a Volume. The pruning (or retention) durations are
114 for: Volumes (Media records), Jobs (Job records), and Files (File records).
115 The durations inter-depend a bit because if Bacula prunes a Volume, it
116 automatically removes all the Job records, and all the File records. Also when
117 a Job record is pruned, all the File records for that Job are also pruned
118 (deleted) from the catalog. 
119
120 Having the File records in the database means that you can examine all the
121 files backed up for a particular Job. They take the most space in the catalog
122 (probably 90-95\% of the total). When the File records are pruned, the Job
123 records can remain, and you can still examine what Jobs ran, but not the
124 details of the Files backed up. In addition, without the File records, you
125 cannot use the Console restore command to restore the files. 
126
127 When a Job record is pruned, the Volume (Media record) for that Job can still
128 remain in the database, and if you do a "list volumes", you will see the
129 volume information, but the Job records (and its File records) will no longer
130 be available. 
131
132 In each case, pruning removes information about where older files are, but it
133 also prevents the catalog from growing to be too large. You choose the
134 retention periods in function of how many files you are backing up and the
135 time periods you want to keep those records online, and the size of the
136 database. You can always re-insert the records (with 98\% of the original data)
137 by using "bscan" to scan in a whole Volume or any part of the volume that
138 you want. 
139
140 By setting {\bf AutoPrune} to {\bf yes} you will permit {\bf Bacula} to
141 automatically prune all Volumes in the Pool when a Job needs another Volume.
142 Volume pruning means removing records from the catalog. It does not shrink the
143 size of the Volume or affect the Volume data until the Volume gets
144 overwritten. When a Job requests another volume and there are no Volumes with
145 Volume Status {\bf Append} available, Bacula will begin volume pruning. This
146 means that all Jobs that are older than the {\bf VolumeRetention} period will
147 be pruned from every Volume that has Volume Status {\bf Full} or {\bf Used}
148 and has Recycle set to {\bf yes}. Pruning consists of deleting the
149 corresponding Job, File, and JobMedia records from the catalog database. No
150 change to the physical data on the Volume occurs during the pruning process.
151 When all files are pruned from a Volume (i.e. no records in the catalog), the
152 Volume will be marked as {\bf Purged} implying that no Jobs remain on the
153 volume. The Pool records that control the pruning are described below. 
154
155 \begin{description}
156
157 \item [AutoPrune = \lt{}yes|no\gt{}]
158    \index[console]{AutoPrune  }
159    If AutoPrune is set to  {\bf yes} (default), Bacula
160    will  automatically apply the Volume retention period when running a Job  and
161    it needs a new Volume but no appendable volumes are available.  At that point,
162    Bacula will prune all Volumes that can be pruned  (i.e. AutoPrune set) in an
163    attempt to find a usable volume. If  during the autoprune, all files are
164    pruned from the Volume, it  will be marked with VolStatus {\bf Purged}.  The
165    default is {\bf yes}. Note, that although the File and Job records may be 
166    pruned from the catalog, a Volume will be marked Purged (and hence 
167    ready for recycling) if the Volume status is Append, Full, Used, or Error.
168    If the Volume has another status, such as Archive, Read-Only, Disabled,
169    Busy, or Cleaning, the Volume status will not be changed to Purged.
170
171 \item [Volume Retention = \lt{}time-period-specification\gt{}]
172    \index[console]{Volume Retention}
173    The Volume Retention record defines the length of time that Bacula will
174    guarantee that the Volume is not reused counting from the time the last
175    job stored on the Volume terminated.  A key point is that this time
176    period is not even considered as long at the Volume remains appendable.
177    The Volume Retention period count down begins only when the Append
178    status has been changed to some othe status (Full, Used, Purged, ...).
179
180    When this time period expires, and if {\bf AutoPrune} is set to {\bf
181    yes}, and a new Volume is needed, but no appendable Volume is available,
182    Bacula will prune (remove) Job records that are older than the specified
183    Volume Retention period.
184
185    The Volume Retention period takes precedence over any Job Retention
186    period you have specified in the Client resource.  It should also be
187    noted, that the Volume Retention period is obtained by reading the
188    Catalog Database Media record rather than the Pool resource record.
189    This means that if you change the VolumeRetention in the Pool resource
190    record, you must ensure that the corresponding change is made in the
191    catalog by using the {\bf update pool} command.  Doing so will insure
192    that any new Volumes will be created with the changed Volume Retention
193    period.  Any existing Volumes will have their own copy of the Volume
194    Retention period that can only be changed on a Volume by Volume basis
195    using the {\bf update volume} command.
196
197    When all file catalog entries are removed from the volume,  its VolStatus is
198    set to {\bf Purged}. The files remain physically  on the Volume until the
199    volume is overwritten.  
200
201    Retention periods are specified in seconds,  minutes, hours, days, weeks,
202    months,  quarters, or years on the record. See the  
203    \ilink{Configuration chapter}{Time} of this  manual for
204    additional details of time specification.  
205
206 The default is 1 year. 
207 % TODO: if that is the format, should it be in quotes? decide on a style
208
209 \item [Recycle = \lt{}yes|no\gt{}]
210    \index[fd]{Recycle  }
211    This statement tells Bacula whether or not the particular Volume can be
212    recycled (i.e.  rewritten).  If Recycle is set to {\bf no} (the
213    default), then even if Bacula prunes all the Jobs on the volume and it
214    is marked {\bf Purged}, it will not consider the tape for recycling.  If
215    Recycle is set to {\bf yes} and all Jobs have been pruned, the volume
216    status will be set to {\bf Purged} and the volume may then be reused
217    when another volume is needed.  If the volume is reused, it is relabeled
218    with the same Volume Name, however all previous data will be lost.
219    \end{description}
220
221    It is also possible to "force" pruning of all Volumes in the Pool
222    associated with a Job by adding {\bf Prune Files = yes} to the Job resource. 
223
224 \label{Recycling}
225 \label{RecyclingAlgorithm}
226 \section{Recycling Algorithm}
227 \index[general]{Algorithm!Recycling }
228 \index[general]{Recycling Algorithm }
229
230 After all Volumes of a Pool have been pruned (as mentioned above, this happens
231 when a Job needs a new Volume and no appendable Volumes are available), Bacula
232 will look for the oldest Volume that is Purged (all Jobs and Files expired),
233 and if the {\bf Recycle} flag is on (Recycle=yes) for that Volume, Bacula will
234 relabel it and write new data on it. 
235
236 As mentioned above, there are two key points for getting a Volume
237 to be recycled. First, the Volume must no longer be marked Append (there
238 are a number of directives to automatically make this change), and second
239 since the last write on the Volume, one or more of the Retention periods
240 must have expired so that there are no more catalog backup job records
241 that reference that Volume.  Once both those conditions are satisfied,
242 the volume can be marked Purged and hence recycled.
243
244 The full algorithm that Bacula uses when it needs a new Volume is: 
245 \index[general]{New Volume Algorithm}
246 \index[general]{Algorithm!New Volume}
247
248 The algorithm described below assumes that AutoPrune is enabled,
249 that Recycling is turned on, and that you have defined
250 appropriate Retention periods, or used the defaults for all these
251 items. 
252
253 \begin{itemize}
254 \item If the request is for an Autochanger device, look only
255    for Volumes in the Autochanger (i.e.  with InChanger set and that have
256    the correct Storage device).        
257 \item Search the Pool for a Volume with VolStatus=Append (if there is more
258    than one, the Volume with the oldest date last written is chosen.  If
259    two have the same date then the one with the lowest MediaId is chosen).
260 \item Search the Pool for a Volume with VolStatus=Recycle and the InChanger
261    flag is set true (if there is more than one, the Volume with the oldest
262    date last written is chosen.  If two have the same date then the one
263    with the lowest MediaId is chosen).
264 \item Try recycling any purged Volumes.
265 \item Prune volumes applying Volume retention period (Volumes with VolStatus 
266    Full, Used, or Append are pruned). Note, even if all the File and Job
267    records are pruned from a Volume, the Volume will not be marked Purged
268    until the Volume retention period expires.
269 \item Search the Pool for a Volume with VolStatus=Purged 
270 \item If a Pool named "Scratch" exists, search for a Volume and if found
271    move it to the current Pool for the Job and use it. Note, when
272    the Scratch Volume is moved into the current Pool, the basic
273    Pool defaults are applied as if it is a newly labeled Volume
274    (equivalent to an {\bf update volume from pool} command).
275 \item If we were looking for Volumes in the Autochanger, go back to
276    step 2 above, but this time, look for any Volume whether or not
277    it is in the Autochanger.                   
278 \item Attempt to create a new Volume if automatic labeling enabled 
279    If Python is enabled, a Python NewVolume event is generated before
280    the Label Format directve is used. If the maximum number of Volumes
281    specified for the pool is reached, a new Volume will not be created.
282 \item Prune the oldest Volume if RecycleOldestVolume=yes (the Volume with the
283    oldest LastWritten date and VolStatus equal to  Full, Recycle, Purged, Used,
284    or Append is chosen). This  record ensures that all retention periods are
285    properly respected. 
286 \item Purge the oldest Volume if PurgeOldestVolume=yes (the Volume  with the
287    oldest LastWritten date and VolStatus equal to  Full, Recycle, Purged, Used,
288    or Append is chosen). We strongly  recommend against the use of {\bf
289    PurgeOldestVolume} as it can quite easily lead to loss of current backup
290    data. 
291 \item Give up and ask operator. 
292 \end{itemize}
293
294 The above occurs when Bacula has finished writing a Volume or when no Volume
295 is present in the drive. 
296
297 On the other hand, if you have inserted a different Volume after the last job,
298 and Bacula recognizes the Volume as valid, it will request authorization from
299 the Director to use this Volume. In this case, if you have set {\bf Recycle
300 Current Volume = yes} and the Volume is marked as Used or Full, Bacula will
301 prune the volume and if all jobs were removed during the pruning (respecting
302 the retention periods), the Volume will be recycled and used. 
303
304 The recycling algorithm in this case is: 
305 \begin{itemize}
306 \item If the VolStatus is {\bf Append} or {\bf Recycle} 
307    is set, the volume  will be used.  
308 \item If {\bf Recycle Current Volume} is set and the  volume is marked {\bf
309    Full} or {\bf Used}, Bacula  will prune the volume (applying the retention
310    period).  If all Jobs are pruned from the volume, it will be  recycled. 
311 \end{itemize}
312
313 This permits users to manually change the Volume every day and load tapes in
314 an order different from what is in the catalog, and if the volume does not
315 contain a current copy of your backup data, it will be used. 
316
317 A few points from Alan Brown to keep in mind:
318
319 \begin{enumerate}
320 \item If a pool doesn't have maximum volumes defined then Bacula will prefer to 
321   demand new volumes over forcibly purging older volumes.
322
323 \item If volumes become free through pruning and the Volume retention period has
324   expired, then they get marked as "purged" and are immediately available for
325   recycling - these will be used in preference to creating new volumes.
326
327 \item If the Job, File, and Volume retention periods are different, then
328   it's common to see a tape with no files or jobs listed in the database,
329   but which is still not marked as "purged".
330 \end{enumerate}
331
332
333 \section{Recycle Status}
334 \index[general]{Status!Recycle }
335 \index[general]{Recycle Status }
336
337 Each Volume inherits the Recycle status (yes or no) from the Pool resource
338 record when the Media record is created (normally when the Volume is labeled).
339 This Recycle status is stored in the Media record of the Catalog. Using
340 the Console program, you may subsequently change the Recycle status for each
341 Volume. For example in the following output from {\bf list volumes}: 
342
343 \footnotesize
344 \begin{verbatim}
345 +----------+-------+--------+---------+------------+--------+-----+
346 | VolumeNa | Media | VolSta | VolByte | LastWritte | VolRet | Rec |
347 +----------+-------+--------+---------+------------+--------+-----+
348 | File0001 | File  | Full   | 4190055 | 2002-05-25 | 14400  | 1   |
349 | File0002 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
350 | File0003 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
351 | File0004 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
352 | File0005 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
353 | File0006 | File  | Full   | 1896460 | 2002-05-26 | 14400  | 1   |
354 | File0007 | File  | Purged | 1896466 | 2002-05-26 | 14400  | 1   |
355 +----------+-------+--------+---------+------------+--------+-----+
356 \end{verbatim}
357 \normalsize
358
359 all the volumes are marked as recyclable, and the last Volume, {\bf File0007}
360 has been purged, so it may be immediately recycled. The other volumes are all
361 marked recyclable and when their Volume Retention period (14400 seconds or four
362 hours) expires, they will be eligible for pruning, and possibly recycling.
363 Even though Volume {\bf File0007} has been purged, all the data on the Volume
364 is still recoverable. A purged Volume simply means that there are no entries
365 in the Catalog. Even if the Volume Status is changed to {\bf Recycle}, the
366 data on the Volume will be recoverable. The data is lost only when the Volume
367 is re-labeled and re-written. 
368
369 To modify Volume {\bf File0001} so that it cannot be recycled, you use the
370 {\bf update volume pool=File} command in the console program, or simply {\bf
371 update} and Bacula will prompt you for the information. 
372
373 \footnotesize
374 \begin{verbatim}
375 +----------+------+-------+---------+-------------+-------+-----+
376 | VolumeNa | Media| VolSta| VolByte | LastWritten | VolRet| Rec |
377 +----------+------+-------+---------+-------------+-------+-----+
378 | File0001 | File | Full  | 4190055 | 2002-05-25  | 14400 | 0   |
379 | File0002 | File | Full  | 1897236 | 2002-05-26  | 14400 | 1   |
380 | File0003 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
381 | File0004 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
382 | File0005 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
383 | File0006 | File | Full  | 1896460 | 2002-05-26  | 14400 | 1   |
384 | File0007 | File | Purged| 1896466 | 2002-05-26  | 14400 | 1   |
385 +----------+------+-------+---------+-------------+-------+-----+
386 \end{verbatim}
387 \normalsize
388
389 In this case, {\bf File0001} will never be automatically recycled. The same
390 effect can be achieved by setting the Volume Status to Read-Only. 
391
392 As you have noted, the Volume Status (VolStatus) column in the 
393 catalog database contains the current status of the Volume, which
394 is normally maintained automatically by Bacula. To give you an
395 idea of some of the values it can take during the life cycle of
396 a Volume, here is a picture created by Arno Lehmann:
397
398 \footnotesize
399 \begin{verbatim}
400 A typical volume life cycle is like this:
401
402               because job count or size limit exceeded
403       Append  ---------------------------------------->  Used
404         ^                                                  |
405         | First Job writes to        Retention time passed |
406         | the volume                   and recycling takes |
407         |                                            place |
408         |                                                  v
409       Recycled <-------------------------------------- Purged
410                      Volume is selected for reuse
411
412 \end{verbatim}
413 \normalsize
414
415
416 \section{Making Bacula Use a Single Tape}
417 \label{singletape}
418 \index[general]{Tape!Making Bacula Use a Single}
419 \index[general]{Making Bacula Use a Single Tape}
420
421 Most people will want Bacula to fill a tape and when it is full, a new tape
422 will be mounted, and so on. However, as an extreme example, it is possible for
423 Bacula to write on a single tape, and every night to rewrite it. To get this
424 to work, you must do two things: first, set the VolumeRetention to less than
425 your save period (one day), and the second item is to make Bacula mark the
426 tape as full after using it once. This is done using {\bf UseVolumeOnce =
427 yes}. If this latter record is not used and the tape is not full after the
428 first time it is written, Bacula will simply append to the tape and eventually
429 request another volume. Using the tape only once, forces the tape to be marked
430 {\bf Full} after each use, and the next time {\bf Bacula} runs, it will
431 recycle the tape. 
432
433 An example Pool resource that does this is: 
434
435 \footnotesize
436 \begin{verbatim}
437 Pool {
438   Name = DDS-4
439   Use Volume Once = yes
440   Pool Type = Backup
441   AutoPrune = yes
442   VolumeRetention = 12h # expire after 12 hours
443   Recycle = yes
444 }
445 \end{verbatim}
446 \normalsize
447
448 \section{Daily, Weekly, Monthly Tape Usage Example}
449 \label{usageexample}
450 \index[general]{Daily, Weekly, Monthly Tape Usage Example }
451 \index[general]{Example!Daily Weekly Monthly Tape Usage }
452
453 This example is meant to show you how one could define a fixed set of volumes
454 that Bacula will rotate through on a regular schedule. There are an infinite
455 number of such schemes, all of which have various advantages and
456 disadvantages. 
457
458 We start with the following assumptions: 
459
460 \begin{itemize}
461 \item A single tape has more than enough capacity to do  a full save.  
462 \item There are ten tapes that are used on a daily basis  for incremental
463    backups. They are prelabeled Daily1 ...  Daily10.  
464 \item There are four tapes that are used on a weekly basis  for full backups.
465    They are labeled Week1 ... Week4.  
466 \item There are 12 tapes that are used on a monthly basis  for full backups.
467    They are numbered Month1 ... Month12  
468 \item A full backup is done every Saturday evening (tape inserted  Friday
469    evening before leaving work).  
470 \item No backups are done over the weekend (this is easy to  change).  
471 \item The first Friday of each month, a Monthly tape is used for  the Full
472    backup.  
473 \item Incremental backups are done Monday - Friday (actually  Tue-Fri
474    mornings). 
475 % TODO: why this "actually"? does this need to be explained?
476    \end{itemize}
477
478 We start the system by doing a Full save to one of the weekly volumes or one
479 of the monthly volumes. The next morning, we remove the tape and insert a
480 Daily tape. Friday evening, we remove the Daily tape and insert the next tape
481 in the Weekly series. Monday, we remove the Weekly tape and re-insert the
482 Daily tape. On the first Friday of the next month, we insert the next Monthly
483 tape in the series rather than a Weekly tape, then continue. When a Daily tape
484 finally fills up, {\bf Bacula} will request the next one in the series, and
485 the next day when you notice the email message, you will mount it and {\bf
486 Bacula} will finish the unfinished incremental backup. 
487
488 What does this give? Well, at any point, you will have the last complete
489 Full save plus several Incremental saves. For any given file you want to
490 recover (or your whole system), you will have a copy of that file every day
491 for at least the last 14 days. For older versions, you will have at least three
492 and probably four Friday full saves of that file, and going back further, you
493 will have a copy of that file made on the beginning of the month for at least
494 a year. 
495
496 So you have copies of any file (or your whole system) for at least a year, but
497 as you go back in time, the time between copies increases from daily to weekly
498 to monthly. 
499
500 What would the Bacula configuration look like to implement such a scheme? 
501
502 \footnotesize
503 \begin{verbatim}
504 Schedule {
505   Name = "NightlySave"
506   Run = Level=Full Pool=Monthly 1st sat at 03:05
507   Run = Level=Full Pool=Weekly 2nd-5th sat at 03:05
508   Run = Level=Incremental Pool=Daily tue-fri at 03:05
509 }
510 Job {
511   Name = "NightlySave"
512   Type = Backup
513   Level = Full
514   Client = LocalMachine
515   FileSet = "File Set"
516   Messages = Standard
517   Storage = DDS-4
518   Pool = Daily
519   Schedule = "NightlySave"
520 }
521 # Definition of file storage device
522 Storage {
523   Name = DDS-4
524   Address = localhost
525   SDPort = 9103
526   Password = XXXXXXXXXXXXX
527   Device = FileStorage
528   Media Type = 8mm
529 }
530 FileSet {
531   Name = "File Set"
532   Include = signature=MD5 {
533     fffffffffffffffff
534   }
535   Exclude = { *.o }
536 }
537 Pool {
538   Name = Daily
539   Pool Type = Backup
540   AutoPrune = yes
541   VolumeRetention = 10d   # recycle in 10 days
542   Maximum Volumes = 10
543   Recycle = yes
544 }
545 Pool {
546   Name = Weekly
547   Use Volume Once = yes
548   Pool Type = Backup
549   AutoPrune = yes
550   VolumeRetention = 30d  # recycle in 30 days (default)
551   Recycle = yes
552 }
553 Pool {
554   Name = Monthly
555   Use Volume Once = yes
556   Pool Type = Backup
557   AutoPrune = yes
558   VolumeRetention = 365d  # recycle in 1 year
559   Recycle = yes
560 }
561 \end{verbatim}
562 \normalsize
563
564 \section{ Automatic Pruning and Recycling Example}
565 \label{PruningExample}
566 \index[general]{Automatic Pruning and Recycling Example }
567 \index[general]{Example!Automatic Pruning and Recycling }
568
569 Perhaps the best way to understand the various resource records that come into
570 play during automatic pruning and recycling is to run a Job that goes through
571 the whole cycle. If you add the following resources to your Director's
572 configuration file: 
573
574 \footnotesize
575 \begin{verbatim}
576 Schedule {
577   Name = "30 minute cycle"
578   Run = Level=Full Pool=File Messages=Standard Storage=File
579          hourly at 0:05
580   Run = Level=Full Pool=File Messages=Standard Storage=File
581          hourly at 0:35
582 }
583 Job {
584   Name = "Filetest"
585   Type = Backup
586   Level = Full
587   Client=XXXXXXXXXX
588   FileSet="Test Files"
589   Messages = Standard
590   Storage = File
591   Pool = File
592   Schedule = "30 minute cycle"
593 }
594 # Definition of file storage device
595 Storage {
596   Name = File
597   Address = XXXXXXXXXXX
598   SDPort = 9103
599   Password = XXXXXXXXXXXXX
600   Device = FileStorage
601   Media Type = File
602 }
603 FileSet {
604   Name = "Test Files"
605   Include = signature=MD5 {
606     fffffffffffffffff
607   }
608   Exclude = { *.o }
609 }
610 Pool {
611   Name = File
612   Use Volume Once = yes
613   Pool Type = Backup
614   LabelFormat = "File"
615   AutoPrune = yes
616   VolumeRetention = 4h
617   Maximum Volumes = 12
618   Recycle = yes
619 }
620 \end{verbatim}
621 \normalsize
622
623 Where you will need to replace the {\bf ffffffffff}'s by the appropriate files
624 to be saved for your configuration. For the FileSet Include, choose a
625 directory that has one or two megabytes maximum since there will probably be
626 approximately eight copies of the directory that {\bf Bacula} will cycle through. 
627
628 In addition, you will need to add the following to your Storage daemon's
629 configuration file: 
630
631 \footnotesize
632 \begin{verbatim}
633 Device {
634   Name = FileStorage
635   Media Type = File
636   Archive Device = /tmp
637   LabelMedia = yes;
638   Random Access = Yes;
639   AutomaticMount = yes;
640   RemovableMedia = no;
641   AlwaysOpen = no;
642 }
643 \end{verbatim}
644 \normalsize
645
646 With the above resources, Bacula will start a Job every half hour that saves a
647 copy of the directory you chose to /tmp/File0001 ... /tmp/File0012. After 4
648 hours, Bacula will start recycling the backup Volumes (/tmp/File0001 ...). You
649 should see this happening in the output produced. Bacula will automatically
650 create the Volumes (Files) the first time it uses them. 
651
652 To turn it off, either delete all the resources you've added, or simply
653 comment out the {\bf Schedule} record in the {\bf Job} resource. 
654
655 \section{Manually Recycling Volumes}
656 \label{manualrecycling}
657 \index[general]{Volumes!Manually Recycling }
658 \index[general]{Manually Recycling Volumes }
659
660 Although automatic recycling of Volumes is implemented in version 1.20 and
661 later (see the 
662 \ilink{Automatic Recycling of Volumes}{RecyclingChapter} chapter of
663 this manual), you may want to manually force reuse (recycling) of a Volume. 
664
665 Assuming that you want to keep the Volume name, but you simply want to write
666 new data on the tape, the steps to take are: 
667
668 \begin{itemize}
669 \item Use the {\bf update volume} command in the Console to  ensure that the
670    {\bf Recycle} field is set to {\bf 1}  
671 \item Use the {\bf purge jobs volume} command in the Console  to mark the
672    Volume as {\bf Purged}. Check by using  {\bf list volumes}. 
673 \end{itemize}
674
675 Once the Volume is marked Purged, it will be recycled the next time a Volume
676 is needed. 
677
678 If you wish to reuse the tape by giving it a new name, follow the following
679 steps: 
680
681 \begin{itemize}
682 \item Use the {\bf purge jobs volume} command in the Console  to mark the
683    Volume as {\bf Purged}. Check by using  {\bf list volumes}.  
684 \item In Bacula version 1.30 or greater, use the Console  {\bf relabel}
685    command to relabel the Volume. 
686 \end{itemize}
687
688 Please note that the relabel command applies only to tape Volumes. 
689
690 For Bacula versions prior to 1.30 or to manually relabel the Volume, use the
691 instructions below: 
692
693 \begin{itemize}
694 \item Use the {\bf delete volume} command in the Console  to delete the Volume
695    from the Catalog.  
696 \item If a different tape is mounted, use the {\bf unmount}  command,
697    remove the tape, and insert the tape to be  renamed.  
698 \item Write an EOF mark in the tape using the following  commands: 
699
700 \footnotesize
701 \begin{verbatim}
702   mt -f /dev/nst0 rewind
703   mt -f /dev/nst0 weof
704 \end{verbatim}
705 \normalsize
706
707 where you replace {\bf /dev/nst0} with the appropriate  device name on your
708 system.  
709 \item Use the {\bf label} command to write a new label to  the tape and to
710    enter it in the catalog. 
711 \end{itemize}
712
713 Please be aware that the {\bf delete} command can be dangerous. Once it is
714 done, to recover the File records, you must either restore your database as it
715 was before the {\bf delete} command, or use the {\bf bscan} utility program to
716 scan the tape and recreate the database entries.