Debian Codegraph @

manuals/en/main/strategies.tex

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