diff options
-rw-r--r-- | obnamlib/plugins/backup_plugin.py | 12 | ||||
-rw-r--r-- | obnamlib/plugins/exclude_caches_plugin.py | 3 | ||||
-rw-r--r-- | obnamlib/plugins/exclude_pathnames_plugin.py | 2 | ||||
-rw-r--r-- | obnamlib/plugins/one_file_system_plugin.py | 45 | ||||
-rw-r--r-- | without-tests | 1 |
5 files changed, 50 insertions, 13 deletions
diff --git a/obnamlib/plugins/backup_plugin.py b/obnamlib/plugins/backup_plugin.py index 5ff54413..39cbb08a 100644 --- a/obnamlib/plugins/backup_plugin.py +++ b/obnamlib/plugins/backup_plugin.py @@ -208,12 +208,6 @@ class BackupPlugin(obnamlib.ObnamPlugin): metavar='URL', group=backup_group) - self.app.settings.boolean( - ['one-file-system'], - 'exclude directories (and their subdirs) ' - 'that are in a different filesystem', - group=backup_group) - self.app.settings.bytesize( ['checkpoint'], 'make a checkpoint after a given SIZE', @@ -696,17 +690,13 @@ class BackupPlugin(obnamlib.ObnamPlugin): if self.just_one_file: return pathname == self.just_one_file - if self.app.settings['one-file-system']: - if st.st_dev != self.root_metadata.st_dev: - logging.debug('Excluding (one-file-system): %s' % pathname) - return False - exclude = [False] self.app.hooks.call( 'backup-exclude', fs=self.fs, pathname=pathname, stat_result=st, + root_metadata=self.root_metadata, exclude=exclude) if exclude[0]: return False diff --git a/obnamlib/plugins/exclude_caches_plugin.py b/obnamlib/plugins/exclude_caches_plugin.py index 6dc0872b..08d19072 100644 --- a/obnamlib/plugins/exclude_caches_plugin.py +++ b/obnamlib/plugins/exclude_caches_plugin.py @@ -41,7 +41,8 @@ class ExcludeCachesPlugin(obnamlib.ObnamPlugin): if self.app.settings['exclude-caches']: self.app.hooks.add_callback('backup-exclude', self.exclude) - def exclude(self, fs=None, pathname=None, stat_result=None, exclude=None): + def exclude(self, fs=None, pathname=None, stat_result=None, exclude=None, + **kwargs): if stat.S_ISDIR(stat_result.st_mode): tag_filename = 'CACHEDIR.TAG' tag_contents = 'Signature: 8a477f597d28d172789f06886806bc55' diff --git a/obnamlib/plugins/exclude_pathnames_plugin.py b/obnamlib/plugins/exclude_pathnames_plugin.py index 8b19985f..1bdf19be 100644 --- a/obnamlib/plugins/exclude_pathnames_plugin.py +++ b/obnamlib/plugins/exclude_pathnames_plugin.py @@ -56,7 +56,7 @@ class ExcludePathnamesPlugin(obnamlib.ObnamPlugin): self.compile_exclusion_patterns() self.compile_inclusion_patterns() - def exclude(self, fs=None, pathname=None, stat_result=None, exclude=None): + def exclude(self, pathname=None, stat_result=None, exclude=None, **kwargs): is_excluded, regexp = self.pathname_excluder.exclude(pathname) if is_excluded: logging.debug('Exclude (pattern): %s', pathname) diff --git a/obnamlib/plugins/one_file_system_plugin.py b/obnamlib/plugins/one_file_system_plugin.py new file mode 100644 index 00000000..da9051c6 --- /dev/null +++ b/obnamlib/plugins/one_file_system_plugin.py @@ -0,0 +1,45 @@ +# Copyright (C) 2015 Lars Wirzenius +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + + +import obnamlib + + +class OneFileSystemPlugin(obnamlib.ObnamPlugin): + + def enable(self): + backup_group = obnamlib.option_group['backup'] = 'Backing up' + + self.app.settings.boolean( + ['one-file-system'], + 'exclude directories (and their subdirs) ' + 'that are in a different filesystem', + group=backup_group) + + self.app.hooks.add_callback('config-loaded', self.config_loaded) + + def config_loaded(self): + if self.app.settings['one-file-system']: + self.app.hooks.add_callback('backup-exclude', self.exclude) + + 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: + logging.debug('Excluding (one-file-system): %s' % pathname) + exclude[0] = True diff --git a/without-tests b/without-tests index 9ec98686..9f171a82 100644 --- a/without-tests +++ b/without-tests @@ -30,3 +30,4 @@ obnamlib/plugins/dump_repo_plugin.py obnamlib/fmt_simple/__init__.py obnamlib/plugins/exclude_pathnames_plugin.py obnamlib/plugins/exclude_caches_plugin.py +obnamlib/plugins/one_file_system_plugin.py |