1 From: "Johan Decock" <jdecock@abis.be>
2 To: bacula-users@lists.sourceforge.net
3 Subject: Re: [Bacula-users] cdwriter
4 Date: Fri, 30 Jan 2004 17:11:34 +0100
6 I thought it would be easy to find them in the archives. I'll post them
7 again. I changed some things in them anyway in the mean time. I also
8 include the Director config. Then you see how they are to be used in
9 Runbefore- and RunafterJobs
11 I'm interested in any remarks or improvements you might have. (I'm
12 still getting started in shell scripting)
16 # Default Bacula Director Configuration file
18 # The only thing that MUST be changed is to add one or more
19 # file or directory names in the Include directive of the
22 # For Bacula release 1.32b (14 Oct 2003) -- mandrake (FiveStar)
24 # You might also want to change the default email address
25 # from root to your address. See the "mail" and "operator"
26 # directives in the Messages resource.
29 Director { # define myself
31 DIRport = 9101 # where we listen for UA connections
32 QueryFile = "/etc/bacula/query.sql"
33 WorkingDirectory = "/var/bacula/working"
34 PidDirectory = "/var/run"
35 Maximum Concurrent Jobs = 1
36 Password = "abis" # Console password
41 Name = "Tosfeb31AllHDD"
45 FileSet = "Tosfeb31All"
50 RunBeforeJob = "/etc/bacula/prepare_DVDspool /mnt/backupdaily 1700000"
51 Write Bootstrap = "/var/bacula/working/Tosfeb31All.bsr"
56 Name = "Tosfeb31AllUSB"
60 FileSet = "Tosfeb31All"
61 Schedule = "WeeklyUSB"
65 Write Bootstrap = "/var/bacula/working/Tosfeb31All.bsr"
70 Name = "Tosfeb31EssentialDVD"
74 FileSet = "Tosfeb31Essential"
75 Schedule = "MonthlyDVD"
79 RunBeforeJob = "/etc/bacula/prepare_DVDspool /mnt/backupdaily 4700000"
80 Write Bootstrap = "/var/bacula/working/Tosfeb31Essential.bsr"
81 RunAfterJob = "/etc/bacula/inventorize_volumes %v"
86 Name = "Tosfeb31AllCompressedDVD"
90 FileSet = "Tosfeb31AllCompressed"
94 RunBeforeJob = "/etc/bacula/prepare_DVDspool /mnt/backupdaily 4700000"
95 Write Bootstrap = "/var/bacula/working/Tosfeb31Essential.bsr"
96 RunAfterJob = "/etc/bacula/inventorize_volumes %v"
101 Name = "Tosfeb32AllHDD"
105 FileSet = "Tosfeb32All"
106 Schedule = "Weekdays"
110 Write Bootstrap = "/var/bacula/working/Tosfeb32All.bsr"
115 Name = "Tosfeb32AllUSB"
119 FileSet = "Tosfeb32All"
120 Schedule = "WeeklyUSB"
124 Write Bootstrap = "/var/bacula/working/Tosfeb32All.bsr"
129 Name = "Tosfeb32EssentialDVD"
133 FileSet = "Tosfeb32Essential"
134 Schedule = "MonthlyDVD"
138 Write Bootstrap = "/var/bacula/working/Tosfeb32System.bsr"
139 RunAfterJob = "/etc/bacula/inventorize_volumes %v"
144 # Name = "Tosfeb30System"
147 # Client = tosfeb30-fd
148 # FileSet = "Tosfeb30System"
149 # Schedule = "WeeklyUSB"
150 # Messages = Standard
153 # Write Bootstrap = "/etc/bacula/working/Tosfeb32System.bsr"
158 Name = "Tosfeb33SystemHDD"
162 FileSet = "Tosfeb33System"
163 Schedule = "Weekdays"
167 Write Bootstrap = "/var/bacula/working/Tosfeb33System.bsr"
172 Name = "Tosfeb33SystemUSB"
176 FileSet = "Tosfeb33System"
177 Schedule = "WeeklyUSB"
181 Write Bootstrap = "/var/bacula/working/Tosfeb33All.bsr"
186 Name = "Tosfeb33EssentialDVD"
190 FileSet = "Tosfeb33Essential"
191 Schedule = "MonthlyDVD"
195 Write Bootstrap = "/var/bacula/working/Tosfeb33Essential.bsr"
196 RunAfterJob = "/etc/bacula/inventorize_volumes %v"
201 Name = "BackupCatalogHDD"
206 Schedule = "Weekdays"
210 # This creates an ASCII copy of the catalog
211 RunBeforeJob = "/etc/bacula/make_catalog_backup -u bacula"
212 # This deletes the copy of the catalog
213 RunAfterJob = "/etc/bacula/delete_catalog_backup"
214 Write Bootstrap = "/var/bacula/working/BackupCatalog.bsr"
215 Priority = 90 # run after main backup
219 Name = "BackupCatalogUSB"
224 Schedule = "WeeklyUSB"
228 # This creates an ASCII copy of the catalog
229 RunBeforeJob = "/etc/bacula/make_catalog_backup -u bacula"
230 # This writes the volume file to the proper USB device
231 RunAfterJob = "/etc/bacula/write_to_USB %v"
232 # RunAfterJob = "/etc/bacula/delete_catalog_backup"
233 Write Bootstrap = "/var/bacula/working/BackupCatalog.bsr"
234 Priority = 90 # run after main backup
238 Name = "BackupCatalogDVD"
243 Schedule = "MonthlyDVD"
247 # This creates an ASCII copy of the catalog
248 RunBeforeJob = "/etc/bacula/make_catalog_backup -u bacula"
249 # This writes the volume file to a DVD
250 RunAfterJob = "/etc/bacula/write_to_DVD %v"
251 Write Bootstrap = "/var/bacula/working/BackupCatalog.bsr"
252 Priority = 90 # run after main backup
255 # Standard Restore template, to be changed by Console program
257 Name = "RestoreFiles"
264 Where = /tmp/bacula-restores
267 # List of files to be backed up
270 Include = signature=MD5 portable=yes {
272 # Put your list of files here, one per line or include an
273 # external list with:
277 # Note: / backs up everything on the root partition.
278 # if you have other partitons such as /usr or /home
279 # you will probably want to add them too.
281 # By default this is defined to point to the Bacula build
282 # directory to give a reasonable FileSet to backup to
283 # disk storage during initial testing.
289 # If you backup the root directory, the following two excluded
290 # files can be useful
292 Exclude = { /proc /tmp /.journal /.fsck }
296 # When to do the backups, full backup on first sunday of the month,
299 Include = signature=MD5 portable=yes {
311 Exclude = {pagefile.sys, *.[Dd][Mm][Pp]}
314 Name = "Tosfeb31AllCompressed"
315 Include = signature=MD5 compression=GZIP portable=yes {
327 Exclude = {pagefile.sys, *.[Dd][Mm][Pp]}
330 Name = "Tosfeb31Essential"
331 Include = signature=MD5 compression=GZIP portable=yes {
337 Exclude = {*.[Tt][Mm][Pp], *.backup.fm, *.backup.book}
341 Include = signature=MD5 portable=yes {
349 Exclude = {pagefile.sys, *.[Dd][Mm][Pp]}
352 Name = "Tosfeb32Essential"
353 Include = signature=MD5 compression=GZIP portable=yes {
357 Exclude = {*.[Tt][Mm][Pp]}
361 Name = "Tosfeb33System"
362 Include = signature=MD5 portable=yes {
372 Exclude = {/var, /proc}
376 Name = "Tosfeb33Essential"
377 Include = signature=MD5 compression=GZIP portable=yes {
385 Run = Full tue-fri at 01:00
390 Run = Full sat at 01:00
395 Run = Full 1st sat at 04:00 # These will remain on site
396 Run = Full 3rd sat at 04:00 # These will be carried off site
399 # This is the backup of the catalog
402 Include = signature=MD5 {
403 /var/bacula/working/bacula.sql
407 # Client (File Services) to backup
410 Address = tosfeb33.abis.be
413 Password = "abis" # password for FileDaemon
414 File Retention = 30 days # 30 days
415 Job Retention = 6 months # six months
416 AutoPrune = yes # Prune expired Jobs/Files
421 Address = tosfeb30.abis.be
425 File Retention = 30 days
426 Job Retention = 6 months
432 Address = tosfeb31.abis.be
436 File Retention = 30 days
437 Job Retention = 6 months
443 Address = tosfeb32.abis.be
447 File Retention = 30 days
448 Job Retention = 6 months
452 # Definiton of file storage device
456 Address = tosfeb33.abis.be
459 Device = HDdriveStorage
465 Address = tosfeb33.abis.be
468 Device = USBdriveStorage
474 Address = tosfeb33.abis.be
477 Device = DVDdriveStorage
481 # Generic catalog service
484 dbname = bacula; user = bacula; password = ""
487 # Reasonable message delivery -- send most everything to email address
491 mailcommand = "/usr/sbin/smtp -h tosfeb32.abis.be -f \"\(Bacula\) %r\" -s \"Bacula: %t %e of %c %l\" %r"
492 operatorcommand = "/usr/sbin/smtp -h tosfeb32.abis.be -f \"\(Bacula\) %r\" -s \"Bacula: Intervention needed for %j\" %r"
493 mail = jdecock@abis.be = all, !skipped
494 operator = jdecock@abis.be = mount
495 console = all, !skipped, !saved
497 # WARNING! the following will create a file that you must cycle from
498 # time to time as it will grow indefinitely. However, it will
499 # also keep all your messages if they scroll off the console.
501 append = "/etc/bacula/working/log" = all, !skipped
504 # Pool definition for daily backup on hard disk in backup server
509 # Recycle Oldest Volume = yes
510 Purge Oldest Volume = yes
512 Maximum Volumes = 4 # Monday through Thursday
513 Volume Retention = 2 weeks
514 Accept Any Volume = yes
515 Maximum Volume Jobs = 4 # 31, 32, 33 and Catalog
516 # Maximum Volume Files = 2
517 Maximum Volume Bytes = 18g
518 Volume Use Duration = 1d
519 Label Format = "HDDVolume"
522 # Pool definition for weekly backup, first on hard disk,
523 #then to be copied on removable USB2 hard disk drives in an AfterRunJob
528 Purge Oldest Volume = yes
530 Maximum Volumes = 3 # We have 3 removable USB2 disks
531 Volume Retention = 2 months
532 Accept Any Volume = yes
533 Maximum Volume Jobs = 4 # 31, 32, 33 and Catalog
534 Maximum Volume Bytes = 18g
535 Volume Use Duration = 1d
536 Label Format = "USBVolume"
539 # Pool definition for monthly backups on DVDspool, to be copied to DVD+/-R media in an AfterRunJob
545 Volume Retention = 2 years
546 Accept Any Volume = yes
547 Maximum Volume Bytes = 2147483500 # 2 GB is the maximum size of a file on an ISO9660 file system
548 Maximum Volume Jobs = 1 # each backup job gets its own set of volumes
549 # Maximum Volume Bytes = 4699990000 # 4 700 000 000 # 4.38 GB is the actual size that will fit on a DVD
550 Volume Use Duration = 1d
551 Label Format = "DVD${Year}-${Month:p/2/0/r}-${Day:p/2/0/r}-${NumVols}"
562 # shell script to initialize environment for creating a backup that will be written to DVD+/-R(W)
564 # it will need to check whether there is enough space on the path supplied as the first parameter
565 # and if there isn't it will need to remove some files.
567 # it will also remove the file where all the volume names are collected during the backup run.
569 path=$1 # /mnt/backupdaily
572 #Define global variable to hold return value from function
576 # Define function to determine free space on a mount point
579 freespace=`df | grep $path | awk '{print $4}'`
580 if [ 0 -ne `expr index "$freespace" %` ] ; then
581 freespace=`df | grep $path | awk '{print $3}'`
584 #Define global variable to hold return value from function
588 # Define function to pad a number with spaces to the left for display
594 while [ ${#stringtopad} -lt $wantedlength ]
596 stringtopad=" "$stringtopad
601 PadSpacesToLeft $quota 9
603 echo "How much free space is needed on $path? $padded"
605 # How much space is there left?
609 PadSpacesToLeft $freespace 9
611 echo "Free space currently available on $path:$padded"
613 # As long as there isn't enough room, delete the oldest DVD volume files
614 while [ $freespace -lt $quota ]
616 # determine which is the oldest DVD volume file in /mnt/backupdaily
617 # ls puts the oldest file on top
618 # head grabs the first line
619 # and awk gets the 9th column of this line, i.e. the file name we were looking for
620 oldestfile=`ls -ralt $path/DVD* | head -n 1 | awk '{print $9}'`
622 echo "Deleting: $oldestfile"
625 # assess how much space there is now
627 PadSpacesToLeft $freespace 9
628 echo "Free space currently available on $path:$padded"
629 # and then we test again.
632 # remove the file where all the volume names will be collected.
633 # so we can have a clean run
635 rm -f /var/bacula/volumes
644 # shell script to inventorize volumes used during a backup
647 # Replace | character with spaces (necessary for the for command)
649 volumes=${volumes//|/ }
651 # For every volume do
653 for i in $volumes ; do
654 echo $i >> /var/bacula/volumes
665 # shell script to copy DVD volume files from /mnt/backupdaily to DVD+/-R(W)
667 # The last volume was not added to the inventory list yet, so we do that first
668 /etc/bacula/inventorize_volumes $1
670 supermount -m=/mnt/cdrom disable
674 # another shell script run as a RunAfterJob has been putting the volume names into a text file
675 # now we retrieve those names and write them to DVD
677 # this awk command produces a space delimited list of the lines of the text file and assigns it to $lines
679 lines=`awk '{print $1}' /var/bacula/volumes`
681 # now we can iterate over those volume names
685 if [ $count -le 1 ] ; then
686 # When creating a DVD with growisofs one needs to use -Z the first time
687 echo "Writing first volume file" $count
688 growisofs -Z /dev/scd0 -R -J /mnt/backupdaily/$i
690 # and -M the for the next volume files
691 echo "Writing another volume file" $count
692 growisofs -M /dev/scd0 -R -J /mnt/backupdaily/$i
700 ls -al /mnt/backupdaily
705 #supermount -m=/mnt/cdrom enable
707 # This is run as a RunAfterJob of the catalog backup. It already had a RunAfterJob, so we execute that here
708 /etc/bacula/delete_catalog_backup
715 This last one is to write to removable USB-storage.
721 # shell script to finalize USB backup
724 echo " Creating mount points, if they don't exist"
725 if ! [ -d /mnt/usbdrv ] ; then
728 if ! [ -d /mnt/usbdrv/bacula ] ; then
729 mkdir /mnt/usbdrv/bacula
731 if ! [ -d /mnt/usbdrv/misc ] ; then
732 mkdir /mnt/usbdrv/misc
734 #unmount all mount points related to USB
736 echo " Making sure no USB devices are mounted"
738 umount /mnt/usbdrv/bacula
739 umount /mnt/usbdrv/misc
740 umount /mnt/removable
741 umount /mnt/removable2
742 umount /mnt/removable3
744 #determine which /dev/sd? contains the right USBVolume for this backup
746 echo " Determining whether the right USB device containing our USBVolume is present physically"
749 for i in sda sdb sdc; do
751 echo " Trying with $sd"
752 mount /dev/$sd /mnt/usbdrv/bacula -t ext2
753 ls -al /mnt/usbdrv/bacula
755 if [ -f /mnt/usbdrv/bacula/$volumename ] ; then
759 umount /mnt/usbdrv/bacula
763 echo " Found: $found containing $volumename "
765 if [ $found != nothing ] ; then
766 # mount /mnt/usbdrv/bacula and /mnt/usbdrv/misc on /dev/sd?1 and /dev/sd?5 respectively
767 mount $found"1" /mnt/usbdrv/bacula -t ext2
768 mount $found"5" /mnt/usbdrv/misc -t vfat
770 # copy Ghost images of Windows system drives, the contents of /etc/bacula/*
771 # and a text file with restore instructions to /mnt/usbdrv/misc
773 echo " Copying Ghost image of TOSFEB31 to /mnt/usbdrv/misc"
774 cp -v /mnt/Ghost/PROD/TOSFEB31/SYSTEMAG.GHO /mnt/usbdrv/misc
775 echo " Copying Ghost image of TOSFEB32 to /mnt/usbdrv/misc"
776 cp -v /mnt/Ghost/PROD/TOSFEB32/COFTF32.GHO /mnt/usbdrv/misc
777 echo " Copying /etc/bacula to /mnt/usbdrv/misc"
778 cp -Rfv /etc/bacula/ /mnt/usbdrv/misc
779 echo " Copying Restore instructions to /mnt/usbdrv/misc"
780 cp -v /etc/bacula/How_To_Restore.txt /mnt/usbdrv/misc
782 # copy the current USBVolume to /mnt/usbdrv/bacula overwriting the previous volume file
784 echo " Copying Bacula USB-volume to /mnt/usbdrv/bacula"
786 # cp -fv /mnt/spool/$volumename /mnt/usbdrv/bacula
788 # give some feedback about what was done
791 echo " Directory contents of /mnt/usbdrv/bacula"
792 ls -al /mnt/usbdrv/bacula
794 echo " Directory contents of /mnt/usbdrv/misc"
795 ls -al /mnt/usbdrv/misc
797 # unmount /mnt/usbdrv/bacula and /mnt/usbdrv/misc
799 echo " Unmounting /mnt/usbdrv/... mount points"
800 umount /mnt/usbdrv/bacula
801 umount /mnt/usbdrv/misc
804 # send emails if correct medium is not present
809 # This is run as a RunAfterJob of the catalog backup. It already had a
810 # RunAfterJob, so we execute that here
812 /etc/bacula/delete_catalog_backup