]> git.sur5r.net Git - bacula/docs/blob - docs/manual-de/disk.tex
Manual updates
[bacula/docs] / docs / manual-de / disk.tex
1 %%
2 %%
3
4 \section*{Basic Volume Management}
5 \label{_ChapterStart39}
6 \index[general]{Basic Volume Management}
7 \index[general]{Management!Basic Volume}
8 \index[general]{Disk Volumes}
9 \addcontentsline{toc}{section}{Basic Volume Management}
10
11 This chapter presents most all the features needed to do Volume management.
12 Most of the concepts apply equally well to both tape and disk Volumes.
13 However, the chapter was originally written to explain backing up to disk, so
14 you will see it is slanted in that direction, but all the directives
15 presented here apply equally well whether your volume is disk or tape. 
16
17 If you have a lot of hard disk storage or you absolutely must have your
18 backups run within a small time window, you may want to direct Bacula to
19 backup to disk Volumes rather than tape Volumes. This chapter is intended to
20 give you some of the options that are available to you so that you can manage
21 either disk or tape volumes. 
22 \label{Concepts}
23
24 \subsection*{Key Concepts and Resource Records}
25 \index[general]{Key Concepts and Resource Records }
26 \index[general]{Records!Key Concepts and Resource }
27 \addcontentsline{toc}{subsection}{Key Concepts and Resource Records}
28
29 Getting Bacula to write to disk rather than tape in the simplest case is
30 rather easy. In the Storage daemon's configuration file, you simply define an
31 {\bf Archive Device} to be a directory. For example, if you want your disk
32 backups to go into the directory {\bf /home/bacula/backups}, you could use the
33 following: 
34
35 \footnotesize
36 \begin{verbatim}
37 Device {
38   Name = FileBackup
39   Media Type = File
40   Archive Device = /home/bacula/backups
41   Random Access = Yes;
42   AutomaticMount = yes;
43   RemovableMedia = no;
44   AlwaysOpen = no;
45 }
46 \end{verbatim}
47 \normalsize
48
49 Assuming you have the appropriate {\bf Storage} resource in your Director's
50 configuration file that references the above Device resource, 
51
52 \footnotesize
53 \begin{verbatim}
54 Storage {
55   Name = FileStorage
56   Address = ...
57   Password = ...
58   Device = FileBackup
59   Media Type = File
60 }
61 \end{verbatim}
62 \normalsize
63
64 Bacula will then write the archive to the file {\bf
65 /home/bacula/backups/\lt{}volume-name\gt{}} where \lt{}volume-name\gt{} is the
66 volume name of a Volume defined in the Pool. For example, if you have labeled
67 a Volume named {\bf Vol001}, Bacula will write to the file {\bf
68 /home/bacula/backups/Vol001}. Although you can later move the archive file to
69 another directory, you should not rename it or it will become unreadable by
70 Bacula. This is because each archive has the filename as part of the internal
71 label, and the internal label must agree with the system filename before
72 Bacula will use it. 
73
74 Although this is quite simple, there are a number of problems. The first is
75 that unless you specify otherwise, Bacula will always write to the same volume
76 until you run out of disk space. This problem is addressed below.
77
78 \subsubsection*{Pool Options to Limit the Volume Usage}
79 \index[general]{Usage!Pool Options to Limit the Volume }
80 \index[general]{Pool Options to Limit the Volume Usage }
81 \addcontentsline{toc}{subsubsection}{Pool Options to Limit the Volume Usage}
82
83 Some of the options you have, all of which are specified in the Pool record,
84 are: 
85
86 \begin{itemize}
87 \item To write each Volume only once (i.e. one Job per Volume or file  in this
88    case), use:
89
90 {\bf UseVolumeOnce = yes}. 
91 \item To write nnn Jobs to each Volume, use:
92
93    {\bf Maximum Volume Jobs = nnn}.  
94 \item To limit the maximum size of each Volume, use:
95
96    {\bf Maximum Volume Bytes = mmmm}.  
97 \item To limit the use time (i.e. write the Volume for  a maximum of 5 days),
98    use:
99
100 {\bf Volume Use Duration = ttt}. 
101 \end{itemize}
102
103 Note that although you probably would not want to limit the number of bytes on
104 a tape as you would on a disk Volume, the other options can be very useful in
105 limiting the time Bacula will use a particular Volume (be it tape or disk).
106 For example, the above directives can allow you to ensure that you rotate
107 through a set of daily Volumes if you wish. 
108
109 As mentioned above, each of those directives is specified in the Pool or
110 Pools that you use for your Volumes. In the case of {\bf Maximum Volume Job},
111 {\bf Maximum Volume Bytes}, and {\bf Volume Use Duration}, you can actually
112 specify the desired value on a Volume by Volume basis. The value specified in
113 the Pool record becomes the default when labeling new Volumes. Once a Volume
114 has been created, it gets its own copy of the Pool defaults, and subsequently
115 changing the Pool will have no effect on existing Volumes. You can either
116 manually change the Volume values, or refresh them from the Pool defaults using
117 the {\bf update volume} command in the Console. As an example
118 of the use of one of the above, suppose your Pool resource contains: 
119
120 \footnotesize
121 \begin{verbatim}
122 Pool {
123   Name = File
124   Pool Type = Backup
125   Volume Use Duration = 23h
126 }
127 \end{verbatim}
128 \normalsize
129
130 then if you run a backup once a day (every 24 hours), Bacula will use a new
131 Volume for each backup, because each Volume it writes can only be used for 23 hours
132 after the first write. Note, setting the use duration to 23 hours is not a very 
133 good solution for tapes unless you have someone on-site during the weekends,
134 because Bacula will want a new Volume and no one will be present to mount it,
135 so no weekend backups will be done until Monday morning.
136
137 \label{AutomaticLabeling}
138 \subsubsection*{Automatic Volume Labeling}
139 \index[general]{Automatic Volume Labeling }
140 \index[general]{Labeling!Automatic Volume }
141 \addcontentsline{toc}{subsubsection}{Automatic Volume Labeling}
142
143 Use of the above records brings up another problem -- that of labeling your
144 Volumes. For automated disk backup, you can either manually label each of your
145 Volumes, or you can have Bacula automatically label new Volumes when they are
146 needed. While, the automatic Volume labeling in version 1.30 and prior is a
147 bit simplistic, but it does allow for automation, the features added in
148 version 1.31 permit automatic creation of a wide variety of labels including
149 information from environment variables and special Bacula Counter variables. 
150 In version 1.37 and later, it is probably much better to use Python scripting 
151 and the NewVolume event since generating Volume labels in a Python script is
152 much easier than trying to figure out Counter variables. See the
153 \ilink{Python Scripting}{_ChapterStart60} chapter of this manual for more
154 details.
155
156 Please note that automatic Volume labeling can also be used with tapes, but it is not
157 nearly so practical since the tapes must be pre-mounted. This requires some
158 user interaction. Automatic labeling from templates does NOT work with
159 autochangers since Bacula will not access unknown slots. There are several
160 methods of labeling all volumes in an autochanger magazine. For more
161 information on this, please see the 
162 \ilink{ Autochanger}{_ChapterStart18} chapter of this manual. 
163
164 Automatic Volume labeling is enabled by making a change to both the Pool
165 resource (Director) and to the Device resource (Storage daemon) shown above.
166 In the case of the Pool resource, you must provide Bacula with a label format
167 that it will use to create new names. In the simplest form, the label format
168 is simply the Volume name, to which Bacula will append a four digit number.
169 This number starts at 0001 and is incremented for each Volume the pool
170 contains. Thus if you modify your Pool resource to be: 
171
172 \footnotesize
173 \begin{verbatim}
174 Pool {
175   Name = File
176   Pool Type = Backup
177   Volume Use Duration = 23h
178   LabelFormat = "Vol"
179 }
180 \end{verbatim}
181 \normalsize
182
183 Bacula will create Volume names Vol0001, Vol0002, and so on when new Volumes
184 are needed. Much more complex and elaborate labels can be created using
185 variable expansion defined in the 
186 \ilink{Variable Expansion}{_ChapterStart50} chapter of this manual. 
187
188 The second change that is necessary to make automatic labeling work is to give
189 the Storage daemon permission to automatically label Volumes. Do so by adding
190 {\bf LabelMedia = yes} to the Device resource as follows: 
191
192 \footnotesize
193 \begin{verbatim}
194 Device {
195   Name = File
196   Media Type = File
197   Archive Device = /home/bacula/backups
198   Random Access = Yes;
199   AutomaticMount = yes;
200   RemovableMedia = no;
201   AlwaysOpen = no;
202   LabelMedia = yes
203 }
204 \end{verbatim}
205 \normalsize
206
207 You can find more details of the {\bf Label Format} Pool record in 
208 \ilink{Label Format}{Label} description of the Pool resource
209 records. 
210
211 \label{Recycling1}
212 \subsubsection*{Restricting the Number of Volumes and Recycling}
213 \index[general]{Recycling!Restricting the Number of Volumes and }
214 \index[general]{Restricting the Number of Volumes and Recycling }
215 \addcontentsline{toc}{subsubsection}{Restricting the Number of Volumes and
216 Recycling}
217
218 Automatic labeling discussed above brings up the problem of Volume management.
219 With the above scheme, a new Volume will be created every day. If you have not
220 specified Retention periods, your Catalog will continue to fill keeping track
221 of all the files Bacula has backed up, and this procedure will create one new
222 archive file (Volume) every day. 
223
224 The tools Bacula gives you to help automatically manage these problems are the
225 following: 
226
227 \begin{enumerate}
228 \item Catalog file record retention periods, the  
229    \ilink{File Retention = ttt}{FileRetention}  record in the Client
230    resource.  
231 \item Catalog job record retention periods, the  
232    \ilink{Job Retention = ttt}{JobRetention}  record in the Client
233    resource.  
234 \item The 
235    \ilink{ AutoPrune = yes}{AutoPrune} record in the Client resource
236    to permit  application of the above two retention periods.  
237 \item The 
238    \ilink{ Volume Retention = ttt}{VolRetention} record in the Pool
239    resource.  
240 \item The 
241    \ilink{ AutoPrune = yes}{PoolAutoPrune} record in the Pool
242    resource to permit  application of the Volume retention period.  
243 \item The 
244    \ilink{ Recycle = yes}{PoolRecycle} record in the Pool resource
245    to permit  automatic recycling of Volumes whose Volume retention period has 
246    expired.  
247 \item The 
248    \ilink{ Recycle Oldest Volume = yes}{RecycleOldest} record in the
249    Pool resource tells Bacula  to Prune the oldest volume in the Pool, and if all
250    files  were pruned to recycle this volume and use it.  
251 \item The 
252    \ilink{ Recycle Current Volume = yes}{RecycleCurrent} record in
253    the Pool resource tells Bacula  to Prune the currently mounted volume in the
254    Pool, and if all files  were pruned to recycle this volume and use it.  
255 \item The 
256    \ilink{ Purge Oldest Volume = yes}{PurgeOldest} record in the
257    Pool resource  permits a forced recycling of the oldest Volume when a new one
258    is  needed.  {\bf N.B. This record ignores retention periods! We highly
259    recommend  not to use this record, but instead use Recycle Oldest Volume}  
260 \item The 
261    \ilink{ Maximum Volumes = nnn}{MaxVolumes} record in the Pool
262    resource to limit  the number of Volumes that can be created. 
263 \end{enumerate}
264
265 The first three records (File Retention, Job Retention, and AutoPrune)
266 determine the amount of time that Job and File records will remain in your
267 Catalog, and they are discussed in detail in the 
268 \ilink{Automatic Volume Recycling}{_ChapterStart22} chapter of
269 this manual. 
270
271 Volume Retention, AutoPrune, and Recycle determine how long Bacula will keep
272 your Volumes before reusing them, and they are also discussed in detail in the
273 \ilink{Automatic Volume Recycling}{_ChapterStart22} chapter of
274 this manual. 
275
276 The Maximum Volumes record can also be used in conjunction with the Volume
277 Retention period to limit the total number of archive Volumes (files) that
278 Bacula will create. By setting an appropriate Volume Retention period, a
279 Volume will be purged just before it is needed and thus Bacula can cycle
280 through a fixed set of Volumes. Cycling through a fixed set of Volumes can
281 also be done by setting {\bf Recycle Oldest Volume = yes} or {\bf Recycle
282 Current Volume = yes}. In this case, when Bacula needs a new Volume, it will
283 prune the specified volume. 
284
285 \label{Example2}
286 \subsection*{An Example}
287 \index[general]{Example }
288 \addcontentsline{toc}{subsection}{Example}
289
290 The following example is not very practical, but can be used to demonstrate
291 the proof of concept in a relatively short period of time. The example
292 consists of a single client that is backed up to a set of 12 archive files
293 (Volumes). Each Volume is used (written) only once, and there are four Full
294 saves done every hour (so the whole thing cycles around after three hours). 
295
296 The Director's configuration file is as follows: 
297
298 \footnotesize
299 \begin{verbatim}
300 Director {
301   Name = my-dir
302   QueryFile = "~/bacula/bin/query.sql"
303   PidDirectory = "~/bacula/working"
304   WorkingDirectory = "~/bacula/working"
305   Password = dir_password
306 }
307 Schedule {
308   Name = "FourPerHour"
309   Run = Level=Full Pool=Recycle Storage=FileStorage hourly at 0:05
310   Run = Level=Full Pool=Recycle Storage=FileStorage hourly at 0:20
311   Run = Level=Full Pool=Recycle Storage=FileStorage hourly at 0:35
312   Run = Level=Full Pool=Recycle Storage=FileStorage hourly at 0:50
313 }
314 Job {
315   Name = "RecycleExample"
316   Type = Backup
317   Level = Full
318   Client = Rufus
319   FileSet= "Example FileSet"
320   Messages = Standard
321   Storage = FileStorage
322   Pool = Recycle
323   Schedule = FourPerHour
324 }
325 FileSet {
326   Name = "Example FileSet"
327   Include = compression=GZIP signature=SHA1 {
328     /home/kern/bacula/bin
329   }
330 }
331 Client {
332   Name = Rufus
333   Address = rufus
334   Catalog = BackupDB
335   Password = client_password
336 }
337 Storage {
338   Name = FileStorage
339   Address = rufus
340   Password = local_storage_password
341   Device = RecycleDir
342   Media Type = File
343 }
344 Catalog {
345   Name = BackupDB
346   dbname = bacula; user = bacula; password = ""
347 }
348 Messages {
349   Name = Standard
350   ...
351 }
352 Pool {
353   Name = Recycle
354   Use Volume Once = yes
355   Pool Type = Backup
356   LabelFormat = "Vol"
357   AutoPrune = yes
358   VolumeRetention = 2h
359   Maximum Volumes = 12
360   Recycle = yes
361 }
362 \end{verbatim}
363 \normalsize
364
365 and the Storage daemon's configuration file is: 
366
367 \footnotesize
368 \begin{verbatim}
369 Storage {
370   Name = my-sd
371   WorkingDirectory = "~/bacula/working"
372   Pid Directory = "~/bacula/working"
373   MaximumConcurrentJobs = 10
374 }
375 Director {
376   Name = my-dir
377   Password = local_storage_password
378 }
379 Device {
380   Name = RecycleDir
381   Media Type = File
382   Archive Device = /home/bacula/backups
383   LabelMedia = yes;
384   Random Access = Yes;
385   AutomaticMount = yes;
386   RemovableMedia = no;
387   AlwaysOpen = no;
388 }
389 Messages {
390   Name = Standard
391   director = my-dir = all
392 }
393 \end{verbatim}
394 \normalsize
395
396 In this example, the Jobs will be backed up to directory {\bf
397 /home/bacula/backups} with Volume names Vol0001, Vol0002, ... Vol0012. Every
398 backup Job will write a new volume cycling through the volume numbers, and two
399 hours after a job has started, the volume will be pruned {\bf Volume Retention
400 = 2h}. 
401
402 With a little bit of work, you can change the above example into a weekly or
403 monthly cycle (take care about the amount of archive disk space used). 
404
405 \label{MultipleDisks}
406 \subsection*{Backing up to Multiple Disks}
407 \index[general]{Disks!Backing up to Multiple }
408 \index[general]{Backing up to Multiple Disks }
409 \addcontentsline{toc}{subsection}{Backing up to Multiple Disks}
410
411 Bacula can, of course, use multiple disks, but in general, each disk must be a
412 separate Device specification in the Storage daemon's conf file, and you must
413 then select what clients to backup to each disk. 
414
415 The situation is a bit more complicated if you want to treat two disk drives
416 logically as a single drive, which Bacula does not directly support. However,
417 it is possible to back up your data to multiple disks as if they were a single
418 drive by linking the Volumes from the first disk to the second disk. 
419
420 For example, assume that you have two disks named {\bf /disk1} and {\bf
421 /disk2>}. If you then create a standard Storage daemon Device resource for
422 backing up to the first disk, it will look like the following: 
423
424 \footnotesize
425 \begin{verbatim}
426 Device {
427   Name = client1
428   Media Type = File
429   Archive Device = /disk1
430   LabelMedia = yes;
431   Random Access = Yes;
432   AutomaticMount = yes;
433   RemovableMedia = no;
434   AlwaysOpen = no;
435 }
436 \end{verbatim}
437 \normalsize
438
439 Since there is no way to get the above Device resource to reference both {\bf
440 /disk1} and {\bf /disk2} we do it by pre-creating Volumes on /disk2 with the
441 following: 
442
443 \footnotesize
444 \begin{verbatim}
445 ln -s /disk2/Disk2-vol001 /disk1/Disk2-vol001
446 ln -s /disk2/Disk2-vol002 /disk1/Disk2-vol002
447 ln -s /disk2/Disk2-vol003 /disk1/Disk2-vol003
448 ...
449 \end{verbatim}
450 \normalsize
451
452 At this point, you can label the Volumes as Volume {\bf Disk2-vol001}, {\bf
453 Disk2-vol002}, ... and Bacula will use them as if they were on /disk1 but
454 actually write the data to /disk2. The only minor inconvenience with this
455 method is that you must explicitly name the disks and cannot use automatic
456 labeling unless you arrange to have the labels exactly match the links you
457 have created. 
458 \label{MultipleClients}
459
460 \subsection*{Considerations for Multiple Clients}
461 \index[general]{Clients!Considerations for Multiple }
462 \index[general]{Considerations for Multiple Clients }
463 \addcontentsline{toc}{subsection}{Considerations for Multiple Clients}
464
465 If we take the above example and add a second Client, here are a few
466 considerations: 
467
468 \begin{itemize}
469 \item Although the second client can write to the same set of  Volumes, you
470    will probably want to write to a different  set. 
471 \item You can write to a different set of Volumes by defining  a second Pool,
472    which has a different name and a different  {\bf LabelFormat}.  
473 \item If you wish the Volumes for the second client to go into  a different
474    directory (perhaps even on a different filesystem  to spread the load), you
475    would do so by defining a second  Device resource in the Storage daemon. The
476 {\bf Name}  must be different, and the {\bf Archive Device} could  be
477 different. To ensure that Volumes are never mixed from  one pool to another,
478 you might also define a different  MediaType (e.g. {\bf File1}). 
479 \end{itemize}
480
481 In this example, we have two clients, each with a different Pool and a
482 different number of archive files retained. They also write to different
483 directories with different Volume labeling. 
484
485 The Director's configuration file is as follows: 
486
487 \footnotesize
488 \begin{verbatim}
489 Director {
490   Name = my-dir
491   QueryFile = "~/bacula/bin/query.sql"
492   PidDirectory = "~/bacula/working"
493   WorkingDirectory = "~/bacula/working"
494   Password = dir_password
495 }
496 # Basic weekly schedule
497 Schedule {
498   Name = "WeeklySchedule"
499   Run = Level=Full fri at 1:30
500   Run = Level=Incremental sat-thu at 1:30
501 }
502 FileSet {
503   Name = "Example FileSet"
504   Include = compression=GZIP signature=SHA1 {
505     /home/kern/bacula/bin
506   }
507 }
508 Job {
509   Name = "Backup-client1"
510   Type = Backup
511   Level = Full
512   Client = client1
513   FileSet= "Example FileSet"
514   Messages = Standard
515   Storage = File1
516   Pool = client1
517   Schedule = "WeeklySchedule"
518 }
519 Job {
520   Name = "Backup-client2"
521   Type = Backup
522   Level = Full
523   Client = client2
524   FileSet= "Example FileSet"
525   Messages = Standard
526   Storage = File2
527   Pool = client2
528   Schedule = "WeeklySchedule"
529 }
530 Client {
531   Name = client1
532   Address = client1
533   Catalog = BackupDB
534   Password = client1_password
535   File Retention = 7d
536 }
537 Client {
538   Name = client2
539   Address = client2
540   Catalog = BackupDB
541   Password = client2_password
542 }
543 # Two Storage definitions permits different directories
544 Storage {
545   Name = File1
546   Address = rufus
547   Password = local_storage_password
548   Device = client1
549   Media Type = File
550 }
551 Storage {
552   Name = File2
553   Address = rufus
554   Password = local_storage_password
555   Device = client2
556   Media Type = File
557 }
558 Catalog {
559   Name = BackupDB
560   dbname = bacula; user = bacula; password = ""
561 }
562 Messages {
563   Name = Standard
564   ...
565 }
566 # Two pools permits different cycling periods and Volume names
567 # Cycle through 15 Volumes (two weeks)
568 Pool {
569   Name = client1
570   Use Volume Once = yes
571   Pool Type = Backup
572   LabelFormat = "Client1-"
573   AutoPrune = yes
574   VolumeRetention = 13d
575   Maximum Volumes = 15
576   Recycle = yes
577 }
578 # Cycle through 8 Volumes (1 week)
579 Pool {
580   Name = client2
581   Use Volume Once = yes
582   Pool Type = Backup
583   LabelFormat = "Client2-"
584   AutoPrune = yes
585   VolumeRetention = 6d
586   Maximum Volumes = 8
587   Recycle = yes
588 }
589 \end{verbatim}
590 \normalsize
591
592 and the Storage daemon's configuration file is: 
593
594 \footnotesize
595 \begin{verbatim}
596 Storage {
597   Name = my-sd
598   WorkingDirectory = "~/bacula/working"
599   Pid Directory = "~/bacula/working"
600   MaximumConcurrentJobs = 10
601 }
602 Director {
603   Name = my-dir
604   Password = local_storage_password
605 }
606 # Archive directory for Client1
607 Device {
608   Name = client1
609   Media Type = File
610   Archive Device = /home/bacula/client1
611   LabelMedia = yes;
612   Random Access = Yes;
613   AutomaticMount = yes;
614   RemovableMedia = no;
615   AlwaysOpen = no;
616 }
617 # Archive directory for Client2
618 Device {
619   Name = client2
620   Media Type = File
621   Archive Device = /home/bacula/client2
622   LabelMedia = yes;
623   Random Access = Yes;
624   AutomaticMount = yes;
625   RemovableMedia = no;
626   AlwaysOpen = no;
627 }
628 Messages {
629   Name = Standard
630   director = my-dir = all
631 }
632 \end{verbatim}
633 \normalsize