From f669e3130598a1c20843df28f44a417bc66f01c8 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Sat, 13 Feb 2016 21:05:34 +0100 Subject: [PATCH] Made globing for source_directories the default. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don’t remove non existing files/directories from the list and let attic/borg handle this. --- NEWS | 1 + README.md | 4 ++-- atticmatic/backends/shared.py | 8 +++----- atticmatic/tests/unit/backends/test_shared.py | 1 - sample/config | 4 ++-- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/NEWS b/NEWS index 412e8bc5f..77042d950 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ * Fixed handling of repeated spaces in source_directories which resulted in backup up everything. * Added support for --one-file-system for Borg. * Support borg create --umask. + * Added support for file globs in source_directories. 0.1.7 diff --git a/README.md b/README.md index d29687e1e..1082ff822 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,8 @@ Here's an example config file: ```INI [location] # Space-separated list of source directories to backup. -source_directories: /home /etc -# source_directories_glob: 1 +# Globs are expanded. +source_directories: /home /etc /var/log/syslog* # Path to local or remote backup repository. repository: user@backupserver:sourcehostname.attic diff --git a/atticmatic/backends/shared.py b/atticmatic/backends/shared.py index 65a39dfae..8026540bd 100644 --- a/atticmatic/backends/shared.py +++ b/atticmatic/backends/shared.py @@ -21,7 +21,6 @@ CONFIG_FORMAT = ( 'location', ( option('source_directories'), - option('source_directories_glob', int, required=False), option('repository'), ), ), @@ -61,16 +60,15 @@ def initialize(storage_config, command): def create_archive( excludes_filename, verbosity, storage_config, source_directories, repository, command, - one_file_system=None, source_directories_glob=None + one_file_system=None ): ''' Given an excludes filename (or None), a vebosity flag, a storage config dict, a space-separated list of source directories, a local or remote repository path, and a command to run, create an attic archive. ''' - sources = tuple(re.split('\s+', source_directories)) - if source_directories_glob: - sources = tuple(chain.from_iterable([glob(x) for x in sources])) + sources = re.split('\s+', source_directories) + sources = tuple(chain.from_iterable([glob(x) if glob(x) else [x] for x in sources])) exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else () compression = storage_config.get('compression', None) compression_flags = ('--compression', compression) if compression else () diff --git a/atticmatic/tests/unit/backends/test_shared.py b/atticmatic/tests/unit/backends/test_shared.py index 684c6d6f3..20a98f6c1 100644 --- a/atticmatic/tests/unit/backends/test_shared.py +++ b/atticmatic/tests/unit/backends/test_shared.py @@ -189,7 +189,6 @@ def test_create_archive_with_globs(): source_directories='setup*', repository='repo', command='attic', - source_directories_glob=1, ) diff --git a/sample/config b/sample/config index c698a91c7..e68137675 100644 --- a/sample/config +++ b/sample/config @@ -1,7 +1,7 @@ [location] # Space-separated list of source directories to backup. -source_directories: /home /etc -# source_directories_glob: 1 +# Globs are expanded. +source_directories: /home /etc /var/log/syslog* # For Borg only, you can specify to stay in same file system (do not cross # mount points).