summaryrefslogtreecommitdiffstats
path: root/roles/bacula-dir/templates/etc/bacula/bacula-dir.conf.j2
blob: efaf06a81b5b2a9f4145fea78c8bf3fceaba36dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
#
# Default Bacula Director Configuration file
# For Bacula release 5.2.6 (21 February 2012) -- debian jessie/sid
#

Director {  # define myself
  Name = {{ inventory_hostname_short }}-dir
  @|"sed -n '/^bconsole\\s/ {s//Password = /p; q}' /etc/bacula/passwords-dir"
  Messages = Daemon
  Working Directory = /var/lib/bacula
  Pid Directory = /var/run/bacula
  QueryFile = "/etc/bacula/scripts/query.sql"
  Maximum Concurrent Jobs = 1
  DirAddress = 127.0.0.1
  DirPort = 9101
  FDConnectTimeout = 5 min
  SDConnectTimeout = 5 min
}


JobDefs {
  Name = DefaultJob
  Type = Backup
  Level = Incremental
  Storage = {{ hostvars[ groups['bacula_sd'][0] ].inventory_hostname_short }}-sd
  Messages = Standard
  Accurate = yes
  #Rerun Failed Levels = yes
  Reschedule On Error = yes
  Reschedule Interval = 17 min
  Reschedule Times = 3
  Pool = Default
  Priority = 10
  Write Bootstrap = "/var/lib/bacula/%n.bsr"
}

JobDefs {
  Name = DefaultMySQLJob
  Type = Backup
  Level = Full
  Storage = {{ hostvars[ groups['bacula_sd'][0] ].inventory_hostname_short }}-sd
  Messages = Standard
  FileSet = SQL
  Schedule = WeeklyCycleAfterBackup
  Reschedule On Error = yes
  Reschedule Interval = 17 min
  Reschedule Times = 3
  # This creates an ASCII copy of the databases
  Client Run Before Job = "/usr/bin/mysqldump -r /var/lib/bacula/tmp/dump.sql --events --all-databases"
  # This deletes the copy of the catalog
  RunScript {
    Runs On Client = yes
    Runs On Success = yes
    Runs On Failure = yes
    Runs When = after
    Command = "/bin/rm -f /var/lib/bacula/tmp/dump.sql"
  }
  Pool = database
  Priority = 20
  Write Bootstrap = "/var/lib/bacula/%n.bsr"
}

JobDefs {
  Name = DefaultSlapdJob
  Type = Backup
  Level = Full
  Storage = {{ hostvars[ groups['bacula_sd'][0] ].inventory_hostname_short }}-sd
  Messages = Standard
  FileSet = LDAP
  Schedule = WeeklyCycleAfterBackup
  Reschedule On Error = yes
  Reschedule Interval = 17 min
  Reschedule Times = 3
  # This creates an ASCII copy of the databases
  Client Run Before Job = "/usr/local/sbin/slapcat-all.sh /var/lib/bacula/tmp"
  # This deletes the copy of the catalog
  RunScript {
    Runs On Client = yes
    Runs On Success = yes
    Runs On Failure = yes
    Runs When = after
    Command = "/usr/bin/find /var/lib/bacula/tmp -type f -name '*.ldif' -delete"
  }
  Pool = database
  Priority = 20
  Write Bootstrap = "/var/lib/bacula/%n.bsr"
}


# Backup the director
Job {
  Name = {{ inventory_hostname_short }}-dir
  Client = {{ inventory_hostname_short }}-fd
  JobDefs = DefaultJob
  FileSet = BaculaHome
  Schedule = WeeklyCycle
}

# Backup the mailboxes
{% for h in groups.IMAP | sort %}
Job {
  Name = {{ hostvars[h].inventory_hostname_short }}-mailboxes
  Client = {{ hostvars[h].inventory_hostname_short }}-fd
  JobDefs = DefaultJob
  Accurate = no
  FileSet = Mailboxes
  Pool = mailboxes-inc
  Full Backup Pool = mailboxes-full
  Schedule = Mailboxes13WeeksCycle
  Max Start Delay = 50 min # To avoid too many overlaps
  Max Full Interval = 15 weeks
}
{% endfor %}

# Backup each machine
{% for fd in groups.all | sort %}
Job {
  Name = {{ hostvars[fd].inventory_hostname_short }}
  Client = {{ hostvars[fd].inventory_hostname_short }}-fd
  JobDefs = DefaultJob
  FileSet = FileSetRoot
  Pool = {{ hostvars[fd].inventory_hostname_short }}
  Priority = 15
  Schedule = WeeklyCycle
}
{% endfor %}

{% for fd in groups['MDA'] | union(groups['webmail']) | union(groups['lists']) | union(groups['bacula_dir']) | union(groups['nextcloud']) | sort %}
Job {
  Name = {{ hostvars[fd].inventory_hostname_short }}-mysql
  Client = {{ hostvars[fd].inventory_hostname_short }}-fd
  JobDefs = DefaultMySQLJob
}
{% endfor %}

{% for fd in groups['MDA'] | union(groups['MSA']) | union(groups['LDAP_provider']) | union(groups['MX']) | sort %}
Job {
  Name = {{ hostvars[fd].inventory_hostname_short }}-slapd
  Client = {{ hostvars[fd].inventory_hostname_short }}-fd
  JobDefs = DefaultSlapdJob
}
{% endfor %}


#
# Standard Restore template, to be changed by Console program
# Only one such job is needed for all Jobs/Clients/Storage ...
Job {
  Name = RestoreFiles
  Type = Restore
  Client= {{ inventory_hostname_short }}-fd
  FileSet = FileSetRoot
  Storage = {{ hostvars[ groups['bacula_sd'][0] ].inventory_hostname_short }}-sd
  Pool = Default
  Messages = Standard
  # NOTE: Files are put on the client (FD) that is being restored.
  Where = /tmp/bacula-restores
}


# When to do the backups, full backup on first sunday of the month,
#  differential (i.e. incremental since full) every other sunday,
#  and incremental backups other days
Schedule {
  Name = WeeklyCycle
  Run = Level=Full         Messages=Quiet 1st sun at 01:05
  Run = Level=Differential Messages=Quiet 2nd-5th sun at 01:05
  Run = Level=Incremental  Messages=Quiet mon-sat at 01:05
}

# Backup mailboxes: full backup every 3 months, hourly incremental backup
Schedule {
  Name = Mailboxes13WeeksCycle
  Run = Level=Full Pool=mailboxes-full w04 mon at 02:00
  Run = Level=Full Pool=mailboxes-full w17 mon at 02:00
  Run = Level=Full Pool=mailboxes-full w30 mon at 02:00
  Run = Level=Full Pool=mailboxes-full w43 mon at 02:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 01:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet w05-w16 mon-sun at 02:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet w18-w29 mon-sun at 02:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet w31-w42 mon-sun at 02:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet w44-w03 mon-sun at 02:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 03:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 04:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 05:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 06:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 07:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 08:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 09:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 10:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 11:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 12:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 13:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 14:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 15:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 16:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 17:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 18:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 19:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 20:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 21:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 22:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 23:00
  Run = Level=Incremental Pool=mailboxes-inc FullPool=mailboxes-full Messages=Quiet mon-sun at 00:00
}

# This schedule does the databases. It starts after the WeeklyCycle
Schedule {
  Name = WeeklyCycleAfterBackup
  Run = Level=Full Messages=Quiet sun-sat at 01:10
}


# List of files to be backed up
FileSet {
  Name = BaculaHome
  Include {
    Options {
      signature = SHA1
      compression = GZIP
      verify = pins1
      noatime = yes
    }
    File = /var/lib/bacula
  }
  Exclude {
    File = /var/lib/bacula/tmp
  }
}

FileSet {
  Name = FileSetRoot
  Include {
    # The full /etc/ and /home/, zipped
    Options {
      WildDir = "/home/backup*"
      WildDir = "/home/mail*"
      WildFile = "*~"
      WildFile = "*#"
      Exclude = yes
    }
    Options {
      signature = SHA1
      compression = GZIP
    }
    File = /etc
    File = /home
    Exclude Dir Containing = .no-backup
  }
  Include {
    # /var/lib, excluding databases that can be dumped and backed up separately
    Options {
      WildDir = /var/lib/amavis
      WildDir = "/var/lib/apt*"
      WildDir = /var/lib/aspell
      WildDir = /var/lib/bacula
      WildDir = /var/lib/clamav
      WildDir = "/var/lib/drupal*"
      WildDir = /var/lib/ldap
      WildDir = /var/lib/mailman
      WildDir = /var/lib/mlocate
      WildDir = /var/lib/munin
      WildDir = /var/lib/mysql
      WildDir = /var/lib/postgresql
      WildDir = /var/lib/postgrey
      WildDir = /var/lib/rkhunter
      WildDir = /var/lib/roundcube
      WildDir = /var/lib/tor
      WildDir = /var/lib/usbutils
      WildFile = "*~"
      WildFile = "*#"
      Exclude = yes
    }
    Options {
      signature = SHA1
      compression = GZIP
    }
    File = /var/lib
    Exclude Dir Containing = .no-backup
  }
  Include {
    # Other interesting directories
    Options {
      WildDir = /var/cache
      WildDir = "/var/backup*"
      WildDir = /var/lib # processed earlier
      WildDir = /var/spool
      WildDir = "/var/log*"
      WildDir = /var/tmp
      WildFile = "*~"
      WildFile = "*#"
      Exclude = yes
    }
    Options {
      signature = SHA1
    }
    File = /bin
    File = /boot
    File = /lib
    File = /opt
    File = /root
    File = /sbin
    File = /srv
    File = /usr
    File = /var
    Exclude Dir Containing = .no-backup
  }
  Exclude {
    File = /proc
    File = /sys
    File = /run
    File = /tmp
    File = /.journal
    File = /.fsck
    File = /.autofsck
    File = /net
    File = /mnt
    File = /exports
    File = /misc
    File = /media
  }
}

FileSet {
  Name = SQL
  Include {
    Options {
      signature = SHA1
      compression = GZIP
      verify = s1
    }
    File = /var/lib/bacula/tmp/dump.sql
  }
}

FileSet {
  Name = LDAP
  Include {
    Options {
      signature = SHA1
      compression = GZIP
      verify = s1
      WildFile = "*.ldif"
    }
    Options {
        Wild = "*"
        Exclude = yes
    }
    File = /var/lib/bacula/tmp
  }
}

FileSet {
  Name = Mailboxes
  Include {
    Options {
      WildDir = /home/mail/attachments/queue
      Exclude = yes
    }
    Options {
      signature = SHA1
      verify = pins1
    }
    File = /home/mail/virtual
    File = /home/mail/attachments
    File = /home/mail/spamspool
  }
}


# Client (File Services) to backup
{% for fd in groups.all | sort %}
Client {
  Name = {{ hostvars[fd].inventory_hostname_short }}-fd
  Address = {{ ipsec[ hostvars[fd].inventory_hostname_short ] }}
  FDPort  = 9102
  Catalog = MyCatalog
  @|"sed -n '/^{{ hostvars[fd].inventory_hostname_short }}-fd\\s/ {s//Password = /p; q}' /etc/bacula/passwords-dir"
  File Retention = 4 months
  Job Retention = 5 months
  AutoPrune = yes
  #Maximum Bandwidth = 1mb/s
}
{% endfor %}


# Definition of file storage device
{% for sd in groups['bacula_sd'] | sort %}
Storage {
  Name = {{ hostvars[sd].inventory_hostname_short }}-sd
  Address = {{ ipsec[ hostvars[sd].inventory_hostname_short ] }}
  SDPort  = 9103
  @|"sed -n '/^{{ hostvars[sd].inventory_hostname_short }}-sd\\s/ {s//Password = /p; q}' /etc/bacula/passwords-dir"
  Device = FileStorage
  Media Type = File
}

{% endfor %}

# Default pool definition
Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 3 months
  Maximum Volume Bytes = 5GB
  Label Format = "Default-${NumVols:p/4/0/r}"
}

# Scratch pool definition
Pool {
  Name = Scratch
  Pool Type = Backup
  Maximum Volume Bytes = 5GB
  Label Format = "Scratch-${NumVols:p/4/0/r}"
}

# System pools definition
{% for h in groups.all | sort %}
Pool {
  Name = {{ hostvars[h].inventory_hostname_short }}
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 3 months
  Maximum Volume Bytes = 5GB
  Label Format = "{{ hostvars[h].inventory_hostname_short }}-${NumVols:p/4/0/r}"
}
{% endfor %}

# Mailbox pool definition (full backup)
Pool {
  Name = mailboxes-full
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 26 weeks
  Maximum Volume Bytes = 5GB
  Label Format = "mailboxes-full-${NumVols:p/4/0/r}"
}

# Mailbox pool definition (inc backup)
Pool {
  Name = mailboxes-inc
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 26 weeks
  Maximum Volume Bytes = 5GB
  Label Format = "mailboxes-inc-${NumVols:p/4/0/r}"
}

# Database pool definition
Pool {
  Name = database
  Pool Type = Backup
  Recycle = yes
  AutoPrune = yes
  Volume Retention = 3 months
  Maximum Volume Bytes = 5GB
  Label Format = "database-${NumVols:p/4/0/r}"
}


# Generic catalog service
Catalog {
  Name = MyCatalog
  Password = ""
  DB Name = bacula
  User = bacula
}


# Reasonable message delivery -- send most everything to email address and to the console
Messages {
  Name = Standard
  MailCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula: %t %e of %n %l\" %r"
  Mail = admin@fripost.org = all, !skipped
  OperatorCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula: Intervention needed for %j\" %r"
  Operator = admin@fripost.org = mount
  Console = all, !skipped, !saved
  Append = "/var/log/bacula/bacula.log" = all, !skipped
  Catalog = all
}

# Report upon error only
Messages {
  Name = Quiet
  MailCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula: %t %e of %n %l\" %r"
  Mail On Success = admin@fripost.org = all, !info, !fatal, !skipped, !notsaved, !restored
  MailCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula: %t %e of %n %l\" %r"
  Mail On Error = admin@fripost.org = all, !skipped
  OperatorCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula: Intervention needed for %j\" %r"
  Operator = admin@fripost.org = mount
  Console = all, !info, !restored, !skipped, !saved
  Append = "/var/lib/bacula/log" = all, !skipped
  Catalog = all
}

# Message delivery for daemon messages (no job).
Messages {
  Name = Daemon
  MailCommand = "/usr/sbin/bsmtp -h localhost:16132 -f \"\(Bacula\) \<bacula@fripost.org\>\" -s \"Bacula daemon message\" %r"
  Mail = admin@fripost.org = all, !skipped
  Console = all, !skipped, !saved
  Append = "/var/log/bacula/bacula.log" = all, !skipped
}