1.. _PoolsChapter:
2
3Automated Disk Backup
4=====================
5
6:index:`\ <single: Volumes; Using Pools to Manage>`\  :index:`\ <single: Disk; Automated Backup>`\  :index:`\ <single: Automated Disk Backup>`\  :index:`\ <single: Pool>`\
7
8If you manage five or ten machines and have a nice tape backup, you don’t need Pools, and you may wonder what they are good for. In this chapter, you will see that Pools can help you optimize disk storage space. The same techniques can be applied to a shop that has multiple tape drives, or that wants to mount various different Volumes to meet their needs.
9
10The rest of this chapter will give an example involving backup to disk Volumes, but most of the information applies equally well to tape Volumes.
11
12Given is a scenario, where the size of a full backup is about 15GB.
13
14It is required, that backup data is available for six months. Old files should be available on a daily basis for a week, a weekly basis for a month, then monthly for six months. In addition, offsite capability is not needed. The daily changes amount to about 300MB on the average, or about 2GB per week.
15
16As a consequence, the total volume of data they need to keep to meet their needs is about 100GB (15GB x 6 + 2GB x 5 + 0.3 x 7) = 102.1GB.
17
18The chosen solution was to use a 120GB hard disk – far less than 1/10th the price of a tape drive and the cassettes to handle the same amount of data, and to have the backup software write to disk files.
19
20The rest of this chapter will explain how to setup Bareos so that it would automatically manage a set of disk files with the minimum sysadmin intervention.
21
22.. _OverallDesign:
23
24Overall Design
25--------------
26
27Getting Bareos to write to disk rather than tape in the simplest case is rather easy.
28
29One needs to consider about what happens if we have only a single large Bareos Volume defined on our hard disk. Everything works fine until the Volume fills, then Bareos will ask you to mount a new Volume. This same problem applies to the use of tape Volumes if your tape fills. Being a hard disk and the only one you have, this will be a bit of a problem. It should be obvious that it is better to use a number of smaller Volumes and arrange for Bareos to automatically recycle them so that the disk
30storage space can be reused.
31
32As mentioned, the solution is to have multiple Volumes, or files on the disk. To do so, we need to limit the use and thus the size of a single Volume, by time, by number of jobs, or by size. Any of these would work, but we chose to limit the use of a single Volume by putting a single job in each Volume with the exception of Volumes containing Incremental backup where there will be 6 jobs (a week’s worth of data) per volume. The details of this will be discussed shortly. This is a single client
33backup, so if you have multiple clients you will need to multiply those numbers by the number of clients, or use a different system for switching volumes, such as limiting the volume size.
34
35.. TODO: This chapter will get rewritten. Instead of limiting a Volume to one job, we will utilize ``Max Use Duration = 24 hours``\ . This prevents problems when adding more clients, because otherwise each job has to run seperat.
36
37The next problem to resolve is recycling of Volumes. As you noted from above, the requirements are to be able to restore monthly for 6 months, weekly for a month, and daily for a week. So to simplify things, why not do a Full save once a month, a Differential save once a week, and Incremental saves daily. Now since each of these different kinds of saves needs to remain valid for differing periods, the simplest way to do this (and possibly the only) is to have a separate Pool for each backup
38type.
39
40The decision was to use three Pools: one for Full saves, one for Differential saves, and one for Incremental saves, and each would have a different number of volumes and a different Retention period to accomplish the requirements.
41
42
43
44.. _FullPool:
45
46
47
48Full Pool
49~~~~~~~~~
50
51:index:`\ <single: Pool; Full>`\  :index:`\ <single: Full Pool>`\
52
53Putting a single Full backup on each Volume, will require six Full save Volumes, and a retention period of six months. The Pool needed to do that is:
54
55.. code-block:: bareosconfig
56   :caption: Full-Pool
57
58   Pool {
59     Name = Full-Pool
60     Pool Type = Backup
61     Recycle = yes
62     AutoPrune = yes
63     Volume Retention = 6 months
64     Maximum Volume Jobs = 1
65     Label Format = Full-
66     Maximum Volumes = 9
67   }
68
69Since these are disk Volumes, no space is lost by having separate Volumes for each backup (done once a month in this case). The items to note are the retention period of six months (i.e. they are recycled after six months), that there is one job per volume (Maximum Volume Jobs = 1), the volumes will be labeled Full-0001, ... Full-0006 automatically. One could have labeled these manually from the start, but why not use the features of Bareos.
70
71Six months after the first volume is used, it will be subject to pruning and thus recycling, so with a maximum of 9 volumes, there should always be 3 volumes available (note, they may all be marked used, but they will be marked purged and recycled as needed).
72
73If you have two clients, you would want to set Maximum Volume Jobs to 2 instead of one, or set a limit on the size of the Volumes, and possibly increase the maximum number of Volumes.
74
75
76
77.. _DiffPool:
78
79
80
81Differential Pool
82~~~~~~~~~~~~~~~~~
83
84:index:`\ <single: Pool; Differential>`\  :index:`\ <single: Differential Pool>`\
85
86For the Differential backup Pool, we choose a retention period of a bit longer than a month and ensure that there is at least one Volume for each of the maximum of five weeks in a month. So the following works:
87
88.. code-block:: bareosconfig
89   :caption: Differential Pool
90
91   Pool {
92     Name = Diff-Pool
93     Pool Type = Backup
94     Recycle = yes
95     AutoPrune = yes
96     Volume Retention = 40 days
97     Maximum Volume Jobs = 1
98     Label Format = Diff-
99     Maximum Volumes = 10
100   }
101
102As you can see, the Differential Pool can grow to a maximum of 9 volumes, and the Volumes are retained 40 days and thereafter they can be recycled. Finally there is one job per volume. This, of course, could be tightened up a lot, but the expense here is a few GB which is not too serious.
103
104If a new volume is used every week, after 40 days, one will have used 7 volumes, and there should then always be 3 volumes that can be purged and recycled.
105
106See the discussion above concering the Full pool for how to handle multiple clients.
107
108
109
110.. _IncPool:
111
112
113
114Incremental Pool
115~~~~~~~~~~~~~~~~
116
117:index:`\ <single: Incremental Pool>`\  :index:`\ <single: Pool; Incremental>`\
118
119Finally, here is the resource for the Incremental Pool:
120
121.. code-block:: bareosconfig
122   :caption: Incremental Pool
123
124   Pool {
125     Name = Inc-Pool
126     Pool Type = Backup
127     Recycle = yes
128     AutoPrune = yes
129     Volume Retention = 20 days
130     Maximum Volume Jobs = 6
131     Label Format = Inc-
132     Maximum Volumes = 7
133   }
134
135We keep the data for 20 days rather than just a week as the needs require. To reduce the proliferation of volume names, we keep a week’s worth of data (6 incremental backups) in each Volume. In practice, the retention period should be set to just a bit more than a week and keep only two or three volumes instead of five. Again, the lost is very little and as the system reaches the full steady state, we can adjust these values so that the total disk usage doesn’t exceed the disk capacity.
136
137If you have two clients, the simplest thing to do is to increase the maximum volume jobs from 6 to 12. As mentioned above, it is also possible limit the size of the volumes. However, in that case, you will need to have a better idea of the volume or add sufficient volumes to the pool so that you will be assured that in the next cycle (after 20 days) there is at least one volume that is pruned and can be recycled.
138
139Configuration Files
140-------------------
141
142The following example shows you the actual files used, with only a few minor modifications to simplify things.
143
144The Director’s configuration file is as follows:
145
146.. code-block:: bareosconfig
147   :caption: bareos-dir.conf
148
149   Director {          # define myself
150     Name = bareos-dir
151     QueryFile = "/usr/lib/bareos/scripts/query.sql"
152     Maximum Concurrent Jobs = 1
153     Password = "*** CHANGE ME ***"
154     Messages = Standard
155   }
156
157   JobDefs {
158     Name = "DefaultJob"
159     Type = Backup
160     Level = Incremental
161     Client = bareos-fd
162     FileSet = "Full Set"
163     Schedule = "WeeklyCycle"
164     Storage = File
165     Messages = Standard
166     Pool = Inc-Pool
167     Full Backup Pool = Full-Pool
168     Incremental Backup Pool = Inc-Pool
169     Differential Backup Pool = Diff-Pool
170     Priority = 10
171     Write Bootstrap = "/var/lib/bareos/%c.bsr"
172   }
173
174   Job {
175     Name = client
176     Client = client-fd
177     JobDefs = "DefaultJob"
178     FileSet = "Full Set"
179   }
180
181   # Backup the catalog database (after the nightly save)
182   Job {
183     Name = "BackupCatalog"
184     Client = client-fd
185     JobDefs = "DefaultJob"
186     Level = Full
187     FileSet="Catalog"
188     Schedule = "WeeklyCycleAfterBackup"
189     # This creates an ASCII copy of the catalog
190     # Arguments to make_catalog_backup.pl are:
191     #  make_catalog_backup.pl <catalog-name>
192     RunBeforeJob = "/usr/lib/bareos/scripts/make_catalog_backup.pl MyCatalog"
193     # This deletes the copy of the catalog
194     RunAfterJob  = "/usr/lib/bareos/scripts/delete_catalog_backup"
195     # This sends the bootstrap via mail for disaster recovery.
196     # Should be sent to another system, please change recipient accordingly
197     Write Bootstrap = "|/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) \" -s \"Bootstrap for Job %j\" root@localhost"
198     Priority = 11                   # run after main backup
199   }
200
201   # Standard Restore template, to be changed by Console program
202   Job {
203     Name = "RestoreFiles"
204     Type = Restore
205     Client = client-fd
206     FileSet="Full Set"
207     Storage = File
208     Messages = Standard
209     Pool = Default
210     Where = /tmp/bareos-restores
211   }
212
213   # List of files to be backed up
214   FileSet {
215     Name = "Full Set"
216     Include = {
217       Options {
218         signature=SHA1;
219         compression=GZIP9
220       }
221       File = /
222       File = /usr
223       File = /home
224       File = /boot
225       File = /var
226       File = /opt
227     }
228     Exclude = {
229       File = /proc
230       File = /tmp
231       File = /.journal
232       File = /.fsck
233       ...
234     }
235   }
236
237   Schedule {
238     Name = "WeeklyCycle"
239     Run = Level=Full 1st sun at 2:05
240     Run = Level=Differential 2nd-5th sun at 2:05
241     Run = Level=Incremental mon-sat at 2:05
242   }
243
244   # This schedule does the catalog. It starts after the WeeklyCycle
245   Schedule {
246     Name = "WeeklyCycleAfterBackup"
247     Run = Level=Full sun-sat at 2:10
248   }
249
250   # This is the backup of the catalog
251   FileSet {
252     Name = "Catalog"
253     Include {
254       Options {
255         signature = MD5
256       }
257       File = "/var/lib/bareos/bareos.sql" # database dump
258       File = "/etc/bareos"                # configuration
259     }
260   }
261
262   Client {
263     Name = client-fd
264     Address = client
265     FDPort = 9102
266     Password = " *** CHANGE ME ***"
267     AutoPrune = yes      # Prune expired Jobs/Files
268     Job Retention = 6 months
269     File Retention = 60 days
270   }
271
272   Storage {
273     Name = File
274     Address = localhost
275     Password = " *** CHANGE ME ***"
276     Device = FileStorage
277     Media Type = File
278   }
279
280   Catalog {
281     Name = MyCatalog
282     dbname = bareos; user = bareos; password = ""
283   }
284
285   Pool {
286     Name = Full-Pool
287     Pool Type = Backup
288     Recycle = yes           # automatically recycle Volumes
289     AutoPrune = yes         # Prune expired volumes
290     Volume Retention = 6 months
291     Maximum Volume Jobs = 1
292     Label Format = Full-
293     Maximum Volumes = 9
294   }
295
296   Pool {
297     Name = Inc-Pool
298     Pool Type = Backup
299     Recycle = yes           # automatically recycle Volumes
300     AutoPrune = yes         # Prune expired volumes
301     Volume Retention = 20 days
302     Maximum Volume Jobs = 6
303     Label Format = Inc-
304     Maximum Volumes = 7
305   }
306
307   Pool {
308     Name = Diff-Pool
309     Pool Type = Backup
310     Recycle = yes
311     AutoPrune = yes
312     Volume Retention = 40 days
313     Maximum Volume Jobs = 1
314     Label Format = Diff-
315     Maximum Volumes = 10
316   }
317
318   Messages {
319     Name = Standard
320     mailcommand = "bsmtp -h mail.domain.com -f \"\(Bareos\) %r\"
321         -s \"Bareos: %t %e of %c %l\" %r"
322     operatorcommand = "bsmtp -h mail.domain.com -f \"\(Bareos\) %r\"
323         -s \"Bareos: Intervention needed for %j\" %r"
324     mail = root@domain.com = all, !skipped
325     operator = root@domain.com = mount
326     console = all, !skipped, !saved
327     append = "/home/bareos/bin/log" = all, !skipped
328   }
329
330and the Storage daemon’s configuration file is:
331
332.. code-block:: bareosconfig
333   :caption: bareos-sd.conf
334
335   Storage {               # definition of myself
336     Name = bareos-sd
337   }
338
339   Director {
340     Name = bareos-dir
341     Password = " *** CHANGE ME ***"
342   }
343
344   Device {
345     Name = FileStorage
346     Media Type = File
347     Archive Device = /var/lib/bareos/storage
348     LabelMedia = yes;    # lets Bareos label unlabeled media
349     Random Access = yes;
350     AutomaticMount = yes;   # when device opened, read it
351     RemovableMedia = no;
352     AlwaysOpen = no;
353   }
354
355   Messages {
356     Name = Standard
357     director = bareos-dir = all
358   }
359
360
361
362
363