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