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