4 \chapter{Automated Disk Backup}
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}
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.
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.
22 \index[general]{Problem}
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.
31 \section{The Solution}
32 \index[general]{Solution}
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.
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.
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.
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.
57 \section{Overall Design}
58 \index[general]{Overall Design}
59 \index[general]{Design!Overall}
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
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.
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
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.
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.
100 \subsection{Full Pool}
101 \index[general]{Pool!Full}
102 \index[general]{Full Pool}
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:
114 Volume Retention = 6 months
115 Maximum Volume Jobs = 1
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.
130 \subsection{Differential Pool}
131 \index[general]{Pool!Differential}
132 \index[general]{Differential Pool}
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:
145 Volume Retention = 40 days
146 Maximum Volume Jobs = 1
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.
159 \subsection{Incremental Pool}
160 \index[general]{Incremental Pool}
161 \index[general]{Pool!Incremental}
163 Finally, here is the resource for the Incremental Pool:
172 Volume Retention = 20 days
173 Maximum Volume Jobs = 6
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.
189 \section{The Actual Conf Files}
190 \index[general]{Files!Actual Conf}
191 \index[general]{Actual Conf Files}
193 The following example shows you the actual files used, with only a few minor
194 modifications to simplify things.
196 The Director's configuration file is as follows:
200 Director { # define myself
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 ***"
210 # By default, this job will back up to disk in /tmp
216 Schedule = "WeeklyCycle"
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"
227 # Backup the catalog database (after the nightly save)
229 Name = "BackupCatalog"
233 Schedule = "WeeklyCycleAfterBackup"
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
245 # Standard Restore template, to be changed by Console program
247 Name = "RestoreFiles"
254 Where = /tmp/bacula-restores
259 # List of files to be backed up
262 Include = { Options { signature=SHA1; compression=GZIP9 }
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
285 # This schedule does the catalog. It starts after the WeeklyCycle
287 Name = "WeeklyCycleAfterBackup"
288 Run = Level=Full sun-sat at 2:10
291 # This is the backup of the catalog
294 Include { Options { signature=MD5 }
295 File = /home/bacula/working/bacula.sql
304 Password = " *** CHANGE ME ***"
305 AutoPrune = yes # Prune expired Jobs/Files
306 Job Retention = 6 months
307 File Retention = 60 days
314 Password = " *** CHANGE ME ***"
321 dbname = bacula; user = bacula; password = ""
327 Recycle = yes # automatically recycle Volumes
328 AutoPrune = yes # Prune expired volumes
329 Volume Retention = 6 months
330 Maximum Volume Jobs = 1
338 Recycle = yes # automatically recycle Volumes
339 AutoPrune = yes # Prune expired volumes
340 Volume Retention = 14 days
341 Maximum Volume Jobs = 6
351 Volume Retention = 35 days
352 Maximum Volume Jobs = 1
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
371 and the Storage daemon's configuration file is:
375 Storage { # definition of myself
377 SDPort = 9103 # Director's port
378 WorkingDirectory = "/home/bacula/working"
379 Pid Directory = "/home/bacula/working"
383 Password = " *** CHANGE ME ***"
388 Archive Device = /files/bacula
389 LabelMedia = yes; # lets Bacula label unlabeled media
391 AutomaticMount = yes; # when device opened, read it
397 director = bacula-dir = all