1.. _StrategiesChapter:
2
3Using Tape Drives without Autochanger
4=====================================
5
6:index:`\ <single: Strategy; Backup>`\  :index:`\ <single: Backup Strategies>`\
7
8Although Recycling and Backing Up to Disk Volume have been discussed in previous chapters, this chapter is meant to give you an overall view of possible backup strategies and to explain their advantages and disadvantages.
9
10.. _Simple:
11
12
13
14Simple One Tape Backup
15----------------------
16
17:index:`\ <single: Backup; One Tape>`\  :index:`\ <single: One Tape Backup>`\
18
19Probably the simplest strategy is to back everything up to a single tape and insert a new (or recycled) tape when it fills and Bareos requests a new one.
20
21Advantages
22~~~~~~~~~~
23
24-  The operator intervenes only when a tape change is needed (e.g. once a month).
25
26-  There is little chance of operator error because the tape is not changed daily.
27
28-  A minimum number of tapes will be needed for a full restore. Typically the best case will be one tape and worst two.
29
30-  You can easily arrange for the Full backup to occur a different night of the month for each system, thus load balancing and shortening the backup time.
31
32Disadvantages
33~~~~~~~~~~~~~
34
35-  If your site burns down, you will lose your current backups
36
37-  After a tape fills and you have put in a blank tape, the backup will continue, and this will generally happen during working hours.
38
39Practical Details
40~~~~~~~~~~~~~~~~~
41
42This system is very simple. When the tape fills and Bareos requests a new tape, you unmount the tape from the Console program, insert a new tape and label it. In most cases after the label, Bareos will automatically mount the tape and resume the backup. Otherwise, you simply mount the tape.
43
44Using this strategy, one typically does a Full backup once a week followed by daily Incremental backups. To minimize the amount of data written to the tape, one can do a Full backup once a month on the first Sunday of the month, a Differential backup on the 2nd-5th Sunday of the month, and incremental backups the rest of the week.
45
46.. _Manual:
47
48
49
50Manually Changing Tapes
51-----------------------
52
53:index:`\ <single: Tape; Manually Changing>`\
54
55If you use the strategy presented above, Bareos will ask you to change the tape, and you will unmount it and then remount it when you have inserted the new tape.
56
57If you do not wish to interact with Bareos to change each tape, there are several ways to get Bareos to release the tape:
58
59-  In your Storage daemon’s Device resource, set :strong:`AlwaysOpen = no`\ . In this case, Bareos will release the tape after every job. If you run several jobs, the tape will be rewound and repositioned to the end at the beginning of every job. This is not very efficient, but does let you change the tape whenever you want.
60
61-  Use a RunAfterJob statement to run a script after your last job. This could also be an Admin job that runs after all your backup jobs. The script could be something like:
62
63
64
65   ::
66
67            #!/bin/sh
68            bconsole <<END_OF_DATA
69            release storage=your-storage-name
70            END_OF_DATA
71
72
73
74   In this example, you would have AlwaysOpen=yes, but the release command would tell Bareos to rewind the tape and on the next job assume the tape has changed. This strategy may not work on some systems, or on autochangers because Bareos will still keep the drive open.
75
76-  The final strategy is similar to the previous case except that you would use the unmount command to force Bareos to release the drive. Then you would eject the tape, and remount it as follows:
77
78
79
80   ::
81
82            #!/bin/sh
83            bconsole <<END_OF_DATA
84            unmount storage=your-storage-name
85            END_OF_DATA
86
87            # the following is a shell command
88            mt eject
89
90            bconsole <<END_OF_DATA
91            mount storage=your-storage-name
92            END_OF_DATA
93
94
95
96
97
98.. _Daily:
99
100
101
102Daily Tape Rotation
103-------------------
104
105:index:`\ <single: Rotation; Daily Tape>`\  :index:`\ <single: Daily Tape Rotation>`\
106
107This scheme is quite different from the one mentioned above in that a Full backup is done to a different tape every day of the week. Generally, the backup will cycle continuously through five or six tapes each week. Variations are to use a different tape each Friday, and possibly at the beginning of the month. Thus if backups are done Monday through Friday only, you need only five tapes, and by having two Friday tapes, you need a total of six tapes. Many sites run this way, or using
108modifications of it based on two week cycles or longer.
109
110.. _advantages-1:
111
112Advantages
113~~~~~~~~~~
114
115-  All the data is stored on a single tape, so recoveries are simple and faster.
116
117-  Assuming the previous day’s tape is taken offsite each day, a maximum of one days data will be lost if the site burns down.
118
119.. _disadvantages-1:
120
121Disadvantages
122~~~~~~~~~~~~~
123
124-  The tape must be changed every day requiring a lot of operator intervention.
125
126-  More errors will occur because of human mistakes.
127
128-  If the wrong tape is inadvertently mounted, the Backup for that day will not occur exposing the system to data loss.
129
130-  There is much more movement of the tape each day (rewinds) leading to shorter tape drive life time.
131
132-  Initial setup of Bareos to run in this mode is more complicated than the Single tape system described above.
133
134-  Depending on the number of systems you have and their data capacity, it may not be possible to do a Full backup every night for time reasons or reasons of tape capacity.
135
136.. _practical-details-1:
137
138Practical Details
139~~~~~~~~~~~~~~~~~
140
141The simplest way to "force" Bareos to use a different tape each day is to define a different Pool for each day of the the week a backup is done. In addition, you will need to specify appropriate Job and File retention periods so that Bareos will relabel and overwrite the tape each week rather than appending to it. Nic Bellamy has supplied an actual working model of this which we include here.
142
143What is important is to create a different Pool for each day of the week, and on the run statement in the Schedule, to specify which Pool is to be used. He has one Schedule that accomplishes this, and a second Schedule that does the same thing for the Catalog backup run each day after the main backup (Priorities were not available when this script was written). In addition, he uses a Max Start Delay of 22 hours so that if the wrong tape is premounted by the operator, the job will be
144automatically canceled, and the backup cycle will re-synchronize the next day. He has named his Friday Pool WeeklyPool because in that Pool, he wishes to have several tapes to be able to restore to a time older than one week.
145
146And finally, in his Storage daemon’s Device resource, he has Automatic Mount = yes and Always Open = No. This is necessary for the tape ejection to work in his end_of_backup.sh script below.
147
148For example, his bareos-dir.conf file looks like the following:
149
150
151
152::
153
154
155   # /etc/bareos/bareos-dir.conf
156   #
157   # Bareos Director Configuration file
158   #
159   Director {
160     Name = ServerName
161     DIRport = 9101
162     QueryFile = "/etc/bareos/query.sql"
163     Maximum Concurrent Jobs = 1
164     Password = "console-pass"
165     Messages = Standard
166   }
167   #
168   # Define the main nightly save backup job
169   #
170   Job {
171     Name = "NightlySave"
172     Type = Backup
173     Client = ServerName
174     FileSet = "Full Set"
175     Schedule = "WeeklyCycle"
176     Storage = Tape
177     Messages = Standard
178     Pool = Default
179     Write Bootstrap = "/var/lib/bareos/NightlySave.bsr"
180     Max Start Delay = 22h
181   }
182   # Backup the catalog database (after the nightly save)
183   Job {
184     Name = "BackupCatalog"
185     Type = Backup
186     Client = ServerName
187     FileSet = "Catalog"
188     Schedule = "WeeklyCycleAfterBackup"
189     Storage = Tape
190     Messages = Standard
191     Pool = Default
192     # This creates an ASCII copy of the catalog
193     # WARNING!!! Passing the password via the command line is insecure.
194     # see comments in make_catalog_backup for details.
195     RunBeforeJob = "/usr/lib/bareos/make_catalog_backup -u bareos"
196     # This deletes the copy of the catalog, and ejects the tape
197     RunAfterJob  = "/etc/bareos/end_of_backup.sh"
198     Write Bootstrap = "/var/lib/bareos/BackupCatalog.bsr"
199     Max Start Delay = 22h
200   }
201   # Standard Restore template, changed by Console program
202   Job {
203     Name = "RestoreFiles"
204     Type = Restore
205     Client = ServerName
206     FileSet = "Full Set"
207     Storage = Tape
208     Messages = Standard
209     Pool = Default
210     Where = /tmp/bareos-restores
211   }
212   # List of files to be backed up
213   FileSet {
214     Name = "Full Set"
215     Include = signature=MD5 {
216       /
217       /data
218     }
219     Exclude = { /proc /tmp /.journal }
220   }
221   #
222   # When to do the backups
223   #
224   Schedule {
225     Name = "WeeklyCycle"
226     Run = Level=Full Pool=MondayPool Monday at 8:00pm
227     Run = Level=Full Pool=TuesdayPool Tuesday at 8:00pm
228     Run = Level=Full Pool=WednesdayPool Wednesday at 8:00pm
229     Run = Level=Full Pool=ThursdayPool Thursday at 8:00pm
230     Run = Level=Full Pool=WeeklyPool Friday at 8:00pm
231   }
232   # This does the catalog. It starts after the WeeklyCycle
233   Schedule {
234     Name = "WeeklyCycleAfterBackup"
235     Run = Level=Full Pool=MondayPool Monday at 8:15pm
236     Run = Level=Full Pool=TuesdayPool Tuesday at 8:15pm
237     Run = Level=Full Pool=WednesdayPool Wednesday at 8:15pm
238     Run = Level=Full Pool=ThursdayPool Thursday at 8:15pm
239     Run = Level=Full Pool=WeeklyPool Friday at 8:15pm
240   }
241   # This is the backup of the catalog
242   FileSet {
243     Name = "Catalog"
244     Include = signature=MD5 {
245        /var/lib/bareos/bareos.sql
246     }
247   }
248   # Client (File Services) to backup
249   Client {
250     Name = ServerName
251     Address = dionysus
252     FDPort = 9102
253     Password = "client-pass"
254     File Retention = 30d
255     Job Retention = 30d
256     AutoPrune = yes
257   }
258   # Definition of file storage device
259   Storage {
260     Name = Tape
261     Address = dionysus
262     SDPort = 9103
263     Password = "storage-pass"
264     Device = Tandberg
265     Media Type = MLR1
266   }
267   # Generic catalog service
268   Catalog {
269     Name = MyCatalog
270     dbname = bareos; user = bareos; password = ""
271   }
272   # Reasonable message delivery -- send almost all to email address
273   #  and to the console
274   Messages {
275     Name = Standard
276     mailcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) %r\" -s \"Bareos: %t %e of %c %l\" %r"
277     operatorcommand = "/usr/sbin/bsmtp -h localhost -f \"\(Bareos\) %r\" -s \"Bareos: Intervention needed for %j\" %r"
278     mail = root@localhost = all, !skipped
279     operator = root@localhost = mount
280     console = all, !skipped, !saved
281     append = "/var/lib/bareos/log" = all, !skipped
282   }
283
284   # Pool definitions
285   #
286   # Default Pool for jobs, but will hold no actual volumes
287   Pool {
288     Name = Default
289     Pool Type = Backup
290   }
291   Pool {
292     Name = MondayPool
293     Pool Type = Backup
294     Recycle = yes
295     AutoPrune = yes
296     Volume Retention = 6d
297     Maximum Volume Jobs = 2
298   }
299   Pool {
300     Name = TuesdayPool
301     Pool Type = Backup
302     Recycle = yes
303     AutoPrune = yes
304     Volume Retention = 6d
305     Maximum Volume Jobs = 2
306   }
307   Pool {
308     Name = WednesdayPool
309     Pool Type = Backup
310     Recycle = yes
311     AutoPrune = yes
312     Volume Retention = 6d
313     Maximum Volume Jobs = 2
314   }
315   Pool {
316     Name = ThursdayPool
317     Pool Type = Backup
318     Recycle = yes
319     AutoPrune = yes
320     Volume Retention = 6d
321     Maximum Volume Jobs = 2
322   }
323   Pool {
324     Name = WeeklyPool
325     Pool Type = Backup
326     Recycle = yes
327     AutoPrune = yes
328     Volume Retention = 12d
329     Maximum Volume Jobs = 2
330   }
331   # EOF
332
333
334
335In order to get Bareos to release the tape after the nightly backup, this setup uses a RunAfterJob script that deletes the database dump and then rewinds and ejects the tape. The following is a copy of end_of_backup.sh
336
337
338
339::
340
341   #! /bin/sh
342   /usr/lib/bareos/delete_catalog_backup
343   mt rewind
344   mt eject
345   exit 0
346
347
348
349Finally, if you list his Volumes, you get something like the following:
350
351
352
353::
354
355   *list media
356   Using default Catalog name=MyCatalog DB=bareos
357   Pool: WeeklyPool
358   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
359   | MeId| VolumeName| MedTyp| VolStat| VolBytes  | LastWritten     | VolRet| Recyc|
360   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
361   | 5   | Friday_1  | MLR1  | Used   | 2157171998| 2003-07-11 20:20| 103680| 1    |
362   | 6   | Friday_2  | MLR1  | Append | 0         | 0               | 103680| 1    |
363   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
364   Pool: MondayPool
365   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
366   | MeId| VolumeName| MedTyp| VolStat| VolBytes  | LastWritten     | VolRet| Recyc|
367   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
368   | 2   | Monday    | MLR1  | Used   | 2260942092| 2003-07-14 20:20| 518400| 1    |
369   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
370   Pool: TuesdayPool
371   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
372   | MeId| VolumeName| MedTyp| VolStat| VolBytes  | LastWritten     | VolRet| Recyc|
373   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
374   | 3   | Tuesday   | MLR1  | Used   | 2268180300| 2003-07-15 20:20| 518400| 1    |
375   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
376   Pool: WednesdayPool
377   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
378   | MeId| VolumeName| MedTyp| VolStat| VolBytes  | LastWritten     | VolRet| Recyc|
379   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
380   | 4   | Wednesday | MLR1  | Used   | 2138871127| 2003-07-09 20:2 | 518400| 1    |
381   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
382   Pool: ThursdayPool
383   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
384   | MeId| VolumeName| MedTyp| VolStat| VolBytes  | LastWritten     | VolRet| Recyc|
385   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
386   | 1   | Thursday  | MLR1  | Used   | 2146276461| 2003-07-10 20:50| 518400| 1    |
387   +-----+-----------+-------+--------+-----------+-----------------+-------+------+
388   Pool: Default
389   No results to list.
390
391
392
393
394
395
396