From abb328ff39d4307423b79ef74df515e0116ca136 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Tue, 21 May 2013 22:36:28 +0200 Subject: [PATCH] Add script for selecting which mount points to backup 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 | 18 ++++++++++++++++++ modules/bacula/manifests/client.pp | 4 ++++ modules/bacula/templates/bacula-dir.conf.erb | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 modules/bacula/files/bacula-backup-dirs diff --git a/modules/bacula/files/bacula-backup-dirs b/modules/bacula/files/bacula-backup-dirs new file mode 100644 index 000000000..bff45a5f0 --- /dev/null +++ b/modules/bacula/files/bacula-backup-dirs @@ -0,0 +1,18 @@ +#! /usr/bin/python + +import re + +MI_RE = re.compile(r'(?P\d+) (?P\d+) (?P\d+:\d+) (?P\S+) (?P\S+) (?P\S+) (?P(?:\S+\s)+ )?- (?P\S+) (?P\S+) (?P\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"] diff --git a/modules/bacula/manifests/client.pp b/modules/bacula/manifests/client.pp index b1384901e..b1aa64a02 100644 --- a/modules/bacula/manifests/client.pp +++ b/modules/bacula/manifests/client.pp @@ -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', diff --git a/modules/bacula/templates/bacula-dir.conf.erb b/modules/bacula/templates/bacula-dir.conf.erb index 98d0cf121..8389d9201 100644 --- a/modules/bacula/templates/bacula-dir.conf.erb +++ b/modules/bacula/templates/bacula-dir.conf.erb @@ -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 } -- 2.20.1