]> git.sur5r.net Git - bacula/docs/blob - docs/manual/pools.tex
Update
[bacula/docs] / docs / manual / pools.tex
1 %%
2 %%
3
4 \chapter{Automated Disk Backup}
5 \label{PoolsChapter}
6 \index[general]{Volumes!Using Pools to Manage}
7 \index[general]{Disk!Automated Backup}
8 \index[general]{Using Pools to Manage Volumes}
9 \index[general]{Automated Disk Backup}
10
11 If you manage five or ten machines and have a nice tape backup, you don't need
12 Pools, and you may wonder what they are good for. In this chapter, you will
13 see that Pools can help you optimize disk storage space. The same techniques
14 can be applied to a shop that has multiple tape drives, or that wants to mount
15 various different Volumes to meet their needs. 
16
17 The rest of this chapter will give an example involving backup to disk
18 Volumes, but most of the information applies equally well to tape Volumes. 
19
20 \label{TheProblem}
21 \section{The Problem}
22 \index[general]{Problem}
23
24 A site that I administer (a charitable organization) had a tape DDS-3 tape
25 drive that was failing. The exact reason for the failure is still unknown.
26 Worse yet, their full backup size is about 15GB whereas the capacity of their
27 broken DDS-3 was at best 8GB (rated 6/12). A new DDS-4 tape drive and the
28 necessary cassettes was more expensive than their budget could handle. 
29 \label{TheSolution}
30
31 \section{The Solution}
32 \index[general]{Solution}
33
34 They want to maintain six months of backup data, and be able to access the old
35 files on a daily basis for a week, a weekly basis for a month, then monthly
36 for six months. In addition, offsite capability was not needed (well perhaps
37 it really is, but it was never used). Their daily changes amount to about
38 300MB on the average, or about 2GB per week. 
39
40 As a consequence, the total volume of data they need to keep to meet their
41 needs is about 100GB (15GB x 6 + 2GB x 5 + 0.3 x 7) = 102.1GB. 
42
43 The chosen solution was to buy a 120GB hard disk for next to nothing -- far
44 less than 1/10th the price of a tape drive and the cassettes to handle the
45 same amount of data, and to have Bacula write to disk files. 
46
47 The rest of this chapter will explain how to setup Bacula so that it would
48 automatically manage a set of disk files with the minimum intervention on my
49 part. The system has been running since 22 January 2004 until today (17
50 September 2006) with no intervention, with the exception that I had to
51 % TODO: is this relevant for book? rewrite this part?
52 add a second 120GB hard disk after a year because their needs grew
53 over that time to more than the 120GB (168GB to be exact).  The only other
54 intervention I have made is a periodic (about once a year) Bacula upgrade.
55
56 \label{OverallDesign}
57 \section{Overall Design}
58 \index[general]{Overall Design}
59 \index[general]{Design!Overall}
60
61 Getting Bacula to write to disk rather than tape in the simplest case is
62 rather easy, and is documented in the previous chapter. In addition, all the
63 directives discussed here are explained in that chapter. We'll leave it to you
64 to look at the details there. If you haven't read it and are not familiar with
65 Pools, you probably should at least read it once quickly for the ideas before
66 continuing here. 
67
68 One needs to consider about what happens if we have only a single large Bacula
69 Volume defined on our hard disk. Everything works fine until the Volume fills,
70 then Bacula will ask you to mount a new Volume. This same problem applies to
71 the use of tape Volumes if your tape fills. Being a hard disk and the only one
72 you have, this will be a bit of a problem. It should be obvious that it is
73 better to use a number of smaller Volumes and arrange for Bacula to
74 automatically recycle them so that the disk storage space can be reused. The
75 other problem with a single Volume, is that at the current time (1.34.0)
76 Bacula does not seek within a disk Volume, so restoring a single file can take
77 more time than one would expect. 
78
79 As mentioned, the solution is to have multiple Volumes, or files on the disk.
80 To do so, we need to limit the use and thus the size of a single Volume, by
81 time, by number of jobs, or by size. Any of these would work, but we chose to
82 limit the use of a single Volume by putting a single job in each Volume with
83 the exception of Volumes containing Incremental backup where there will be 6
84 jobs (a week's worth of data) per volume. The details of this will be
85 discussed shortly. 
86
87 The next problem to resolve is recycling of Volumes. As you noted from above,
88 the requirements are to be able to restore monthly for 6 months, weekly for a
89 month, and daily for a week. So to simplify things, why not do a Full save
90 once a month, a Differential save once a week, and Incremental saves daily.
91 Now since each of these different kinds of saves needs to remain valid for
92 differing periods, the simplest way to do this (and possibly the only) is to
93 have a separate Pool for each backup type. 
94
95 The decision was to use three Pools: one for Full saves, one for Differential
96 saves, and one for Incremental saves, and each would have a different number
97 of volumes and a different Retention period to accomplish the requirements. 
98 \label{FullPool}
99
100 \subsection{Full Pool}
101 \index[general]{Pool!Full}
102 \index[general]{Full Pool}
103
104 Putting a single Full backup on each Volume, will require six Full save
105 Volumes, and a retention period of six months. The Pool needed to do that is: 
106
107 \footnotesize
108 \begin{verbatim}
109 Pool {
110   Name = Full-Pool
111   Pool Type = Backup
112   Recycle = yes
113   AutoPrune = yes
114   Volume Retention = 6 months
115   Maximum Volume Jobs = 1
116   Label Format = Full-
117   Maximum Volumes = 6
118 }
119 \end{verbatim}
120 \normalsize
121
122 Since these are disk Volumes, no space is lost by having separate Volumes for
123 each backup (done once a month in this case). The items to note are the
124 retention period of six months (i.e. they are recycled after six months), that
125 there is one job per volume (Maximum Volume Jobs = 1), the volumes will be
126 labeled Full-0001, ... Full-0006 automatically. One could have labeled these
127 manual from the start, but why not use the features of Bacula. 
128 \label{DiffPool}
129
130 \subsection{Differential Pool}
131 \index[general]{Pool!Differential}
132 \index[general]{Differential Pool}
133
134 For the Differential backup Pool, we choose a retention period of a bit longer
135 than a month and ensure that there is at least one Volume for each of the
136 maximum of five weeks in a month. So the following works: 
137
138 \footnotesize
139 \begin{verbatim}
140 Pool {
141   Name = Diff-Pool
142   Pool Type = Backup
143   Recycle = yes
144   AutoPrune = yes
145   Volume Retention = 40 days
146   Maximum Volume Jobs = 1
147   Label Format = Diff-
148   Maximum Volumes = 6
149 }
150 \end{verbatim}
151 \normalsize
152
153 As you can see, the Differential Pool can grow to a maximum of six volumes,
154 and the Volumes are retained 40 days and thereafter they can be recycled. Finally
155 there is one job per volume. This, of course, could be tightened up a lot, but
156 the expense here is a few GB which is not too serious. 
157 \label{IncPool}
158
159 \subsection{Incremental Pool}
160 \index[general]{Incremental Pool}
161 \index[general]{Pool!Incremental}
162
163 Finally, here is the resource for the Incremental Pool: 
164
165 \footnotesize
166 \begin{verbatim}
167 Pool {
168   Name = Inc-Pool
169   Pool Type = Backup
170   Recycle = yes
171   AutoPrune = yes
172   Volume Retention = 20 days
173   Maximum Volume Jobs = 6
174   Label Format = Inc-
175   Maximum Volumes = 5
176 }
177 \end{verbatim}
178 \normalsize
179
180 We keep the data for 20 days rather than just a week as the needs require. To
181 reduce the proliferation of volume names, we keep a week's worth of data (6
182 incremental backups) in each Volume. In practice, the retention period should
183 be set to just a bit more than a week and keep only two or three volumes
184 instead of five. Again, the lost is very little and as the system reaches the
185 full steady state, we can adjust these values so that the total disk usage
186 doesn't exceed the disk capacity. 
187 \label{Example}
188
189 \section{The Actual Conf Files}
190 \index[general]{Files!Actual Conf}
191 \index[general]{Actual Conf Files}
192
193 The following example shows you the actual files used, with only a few minor
194 modifications to simplify things. 
195
196 The Director's configuration file is as follows: 
197
198 \footnotesize
199 \begin{verbatim}
200 Director {          # define myself
201   Name = bacula-dir
202   DIRport = 9101
203   QueryFile = "/home/bacula/bin/query.sql"
204   WorkingDirectory = "/home/bacula/working"
205   PidDirectory = "/home/bacula/working"
206   Maximum Concurrent Jobs = 1
207   Password = " *** CHANGE ME ***"
208   Messages = Standard
209 }
210 #   By default, this job will back up to disk in /tmp
211 Job {
212   Name = client
213   Type = Backup
214   Client = client-fd
215   FileSet = "Full Set"
216   Schedule = "WeeklyCycle"
217   Storage = File
218   Messages = Standard
219   Pool = Default
220   Full Backup Pool = Full-Pool
221   Incremental Backup Pool = Inc-Pool
222   Differential Backup Pool = Diff-Pool
223   Write Bootstrap = "/home/bacula/working/client.bsr"
224   Priority = 10
225 }
226
227 # Backup the catalog database (after the nightly save)
228 Job {
229   Name = "BackupCatalog"
230   Type = Backup
231   Client = client-fd
232   FileSet="Catalog"
233   Schedule = "WeeklyCycleAfterBackup"
234   Storage = File
235   Messages = Standard
236   Pool = Default
237   # This creates an ASCII copy of the catalog
238   RunBeforeJob = "/home/bacula/bin/make_catalog_backup bacula bacula"
239   # This deletes the copy of the catalog
240   RunAfterJob  = "/home/bacula/bin/delete_catalog_backup"
241   Write Bootstrap = "/home/bacula/working/BackupCatalog.bsr"
242   Priority = 11                   # run after main backup
243 }
244
245 # Standard Restore template, to be changed by Console program
246 Job {
247   Name = "RestoreFiles"
248   Type = Restore
249   Client = havana-fd
250   FileSet="Full Set"
251   Storage = File
252   Messages = Standard
253   Pool = Default
254   Where = /tmp/bacula-restores
255 }
256
257
258
259 # List of files to be backed up
260 FileSet {
261   Name = "Full Set"
262   Include = { Options { signature=SHA1; compression=GZIP9 }
263     File = /
264     File = /usr
265     File = /home
266     File = /boot
267     File = /var
268     File = /opt
269   }
270   Exclude = {
271     File = /proc
272     File = /tmp
273     File = /.journal
274     File = /.fsck
275     ...
276   }
277 }
278 Schedule {
279   Name = "WeeklyCycle"
280   Run = Level=Full 1st sun at 2:05
281   Run = Level=Differential 2nd-5th sun at 2:05
282   Run = Level=Incremental mon-sat at 2:05
283 }
284
285 # This schedule does the catalog. It starts after the WeeklyCycle
286 Schedule {
287   Name = "WeeklyCycleAfterBackup"
288   Run = Level=Full sun-sat at 2:10
289 }
290
291 # This is the backup of the catalog
292 FileSet {
293   Name = "Catalog"
294   Include { Options { signature=MD5 }
295     File = /home/bacula/working/bacula.sql
296   }
297 }
298
299 Client {
300   Name = client-fd
301   Address = client
302   FDPort = 9102
303   Catalog = MyCatalog
304   Password = " *** CHANGE ME ***"
305   AutoPrune = yes      # Prune expired Jobs/Files
306   Job Retention = 6 months
307   File Retention = 60 days
308 }
309
310 Storage {
311   Name = File
312   Address = localhost
313   SDPort = 9103
314   Password = " *** CHANGE ME ***"
315   Device = FileStorage
316   Media Type = File
317 }
318
319 Catalog {
320   Name = MyCatalog
321   dbname = bacula; user = bacula; password = ""
322 }
323
324 Pool {
325   Name = Full-Pool
326   Pool Type = Backup
327   Recycle = yes           # automatically recycle Volumes
328   AutoPrune = yes         # Prune expired volumes
329   Volume Retention = 6 months
330   Maximum Volume Jobs = 1
331   Label Format = Full-
332   Maximum Volumes = 8
333 }
334
335 Pool {
336   Name = Inc-Pool
337   Pool Type = Backup
338   Recycle = yes           # automatically recycle Volumes
339   AutoPrune = yes         # Prune expired volumes
340   Volume Retention = 14 days
341   Maximum Volume Jobs = 6
342   Label Format = Inc-
343   Maximum Volumes = 6
344 }
345
346 Pool {
347   Name = Diff-Pool
348   Pool Type = Backup
349   Recycle = yes
350   AutoPrune = yes
351   Volume Retention = 35 days
352   Maximum Volume Jobs = 1
353   Label Format = Diff-
354   Maximum Volumes = 10
355 }
356
357 Messages {
358   Name = Standard
359   mailcommand = "bsmtp -h mail.domain.com -f \"\(Bacula\) %r\"
360       -s \"Bacula: %t %e of %c %l\" %r"
361   operatorcommand = "bsmtp -h mail.domain.com -f \"\(Bacula\) %r\"
362       -s \"Bacula: Intervention needed for %j\" %r"
363   mail = root@domain.com = all, !skipped
364   operator = root@domain.com = mount
365   console = all, !skipped, !saved
366   append = "/home/bacula/bin/log" = all, !skipped
367 }
368 \end{verbatim}
369 \normalsize
370
371 and the Storage daemon's configuration file is: 
372
373 \footnotesize
374 \begin{verbatim}
375 Storage {               # definition of myself
376   Name = bacula-sd
377   SDPort = 9103       # Director's port
378   WorkingDirectory = "/home/bacula/working"
379   Pid Directory = "/home/bacula/working"
380 }
381 Director {
382   Name = bacula-dir
383   Password = " *** CHANGE ME ***"
384 }
385 Device {
386   Name = FileStorage
387   Media Type = File
388   Archive Device = /files/bacula
389   LabelMedia = yes;    # lets Bacula label unlabeled media
390   Random Access = Yes;
391   AutomaticMount = yes;   # when device opened, read it
392   RemovableMedia = no;
393   AlwaysOpen = no;
394 }
395 Messages {
396   Name = Standard
397   director = bacula-dir = all
398 }
399 \end{verbatim}
400 \normalsize