~ubuntu-branches/ubuntu/utopic/bacula-doc/utopic

« back to all changes in this revision

Viewing changes to manual/strategies.tex

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2010-02-09 08:35:53 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100209083553-qsrpwqsv01wnh8lz
Tags: 5.0.0-1
* New upstream release.  Closes: #380247.
* Removed tetex build-deps, fixing FTBFS.  Closes: #562310.
* Build all English manuals mentioned in the README.  The other
  languages are not ready for deployment.  Closes: #561686.
* Switch to dpkg-source 3.0 (quilt) format since upstream ships a
  tar.bz2.

Show diffs side-by-side

added added

removed removed

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