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