Add script for selecting which mount points to backup
authorTollef Fog Heen <tfheen@err.no>
Tue, 21 May 2013 20:36:28 +0000 (22:36 +0200)
committerTollef Fog Heen <tfheen@err.no>
Tue, 21 May 2013 20:36:28 +0000 (22:36 +0200)
baclua-backup-dirs uses /proc/self/mountinfo to find out which mount
points should be backed up, since that's the place to find out about
bind mounts and such in Wheezy and up.

This probably doesn't work so well on kFreeBSD, so we should find a
better solution for them.

modules/bacula/files/bacula-backup-dirs [new file with mode: 0644]
modules/bacula/manifests/client.pp
modules/bacula/templates/bacula-dir.conf.erb

diff --git a/modules/bacula/files/bacula-backup-dirs b/modules/bacula/files/bacula-backup-dirs
new file mode 100644 (file)
index 0000000..bff45a5
--- /dev/null
@@ -0,0 +1,18 @@
+#! /usr/bin/python                                                                                                                           
+
+import re
+
+MI_RE = re.compile(r'(?P<mountid>\d+) (?P<parentid>\d+) (?P<majorminor>\d+:\d+) (?P<root>\S+) (?P<mountpoint>\S+) (?P<options>\S+) (?P<optional>(?:\S+\s)+ )?- (?P<fstype>\S+) (?P<mountsrc>\S+) (?P<superopts>\S+)')
+
+for line in file("/proc/self/mountinfo"):
+    mi = MI_RE.match(line)
+    if mi is None:
+       # XXX: handle error?
+        continue
+    gd = mi.groupdict()
+    # Skip bind mounts
+    if gd.get("root") != "/":
+        continue
+    if gd.get("fstype") not in [ "ext2", "ext3", "ext4", "xfs", "jfs"]:
+        continue
+    print gd["mountpoint"]
index b138490..b1aa64a 100644 (file)
@@ -32,6 +32,10 @@ class bacula::client inherits bacula {
                require => Package['bacula-fd'],
                notify  => Service['bacula-fd'],
        }
+       file { '/usr/local/sbin/bacula-backup-dirs':
+               mode    => '0775',
+               source  => 'puppet:///modules/bacula/bacula-backup-dirs',
+       }
        file { '/usr/local/sbin/postbaculajob':
                mode    => '0775',
                source  => 'puppet:///modules/bacula/postbaculajob',
index 98d0cf1..8389d92 100644 (file)
@@ -44,7 +44,7 @@ FileSet {
       signature = SHA1
       compression = GZIP9
     }
-    File = "\\|bash -c \"df -Pkl -x tmpfs -x iso9660 | tail -n +2 | awk '{print \$NF}' \""
+    File = "|/usr/local/sbin/bacula-backup-dirs"
     # Dont backup directories that contain .nobackup files
     Exclude Dir Containing = .nobackup
   }