summaryrefslogtreecommitdiff
path: root/obnamlib/plugins/one_file_system_plugin.py
diff options
context:
space:
mode:
Diffstat (limited to 'obnamlib/plugins/one_file_system_plugin.py')
-rw-r--r--obnamlib/plugins/one_file_system_plugin.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/obnamlib/plugins/one_file_system_plugin.py b/obnamlib/plugins/one_file_system_plugin.py
index 94101b8d..7b584c88 100644
--- a/obnamlib/plugins/one_file_system_plugin.py
+++ b/obnamlib/plugins/one_file_system_plugin.py
@@ -34,14 +34,28 @@ class OneFileSystemPlugin(obnamlib.ObnamPlugin):
def config_loaded(self):
if self.app.settings['one-file-system']:
+ self.load_mount_points()
self.app.hooks.add_callback('backup-exclude', self.exclude)
+ def load_mount_points(self):
+ try:
+ with open('/proc/mounts', 'r') as f:
+ self.mount_points = self.parse_proc_mounts(f)
+ except EnvironmentError:
+ pass
+
+ def parse_proc_mounts(self, f):
+ return [
+ line.split()[1]
+ for line in f
+ ]
+
def exclude(self, **kwargs):
st = kwargs['stat_result']
root_metadata = kwargs['root_metadata']
pathname = kwargs['pathname']
exclude = kwargs['exclude']
- if st.st_dev != root_metadata.st_dev:
+ if st.st_dev != root_metadata.st_dev or pathname in self.mount_points:
logging.debug('Excluding (one-file-system): %s', pathname)
exclude[0] = True