Made globing for source_directories the default.

Don’t remove non existing files/directories from the list and let
attic/borg handle this.
This commit is contained in:
Robin Schneider 2016-02-13 21:05:34 +01:00
parent 88da0c3039
commit 953d08ba63
No known key found for this signature in database
GPG key ID: 489A4D5EC353C98A
5 changed files with 8 additions and 10 deletions

1
NEWS
View file

@ -3,6 +3,7 @@
* Fixed handling of repeated spaces in source_directories which resulted in backup up everything. * Fixed handling of repeated spaces in source_directories which resulted in backup up everything.
* Added support for --one-file-system for Borg. * Added support for --one-file-system for Borg.
* Support borg create --umask. * Support borg create --umask.
* Added support for file globs in source_directories.
0.1.7 0.1.7

View file

@ -15,8 +15,8 @@ Here's an example config file:
```INI ```INI
[location] [location]
# Space-separated list of source directories to backup. # Space-separated list of source directories to backup.
source_directories: /home /etc # Globs are expanded.
# source_directories_glob: 1 source_directories: /home /etc /var/log/syslog*
# Path to local or remote backup repository. # Path to local or remote backup repository.
repository: user@backupserver:sourcehostname.attic repository: user@backupserver:sourcehostname.attic

View file

@ -21,7 +21,6 @@ CONFIG_FORMAT = (
'location', 'location',
( (
option('source_directories'), option('source_directories'),
option('source_directories_glob', int, required=False),
option('repository'), option('repository'),
), ),
), ),
@ -61,16 +60,15 @@ def initialize(storage_config, command):
def create_archive( def create_archive(
excludes_filename, verbosity, storage_config, source_directories, repository, command, 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 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 list of source directories, a local or remote repository path, and a command to run, create an
attic archive. attic archive.
''' '''
sources = tuple(re.split('\s+', source_directories)) sources = re.split('\s+', source_directories)
if source_directories_glob: sources = tuple(chain.from_iterable([glob(x) if glob(x) else [x] for x in sources]))
sources = tuple(chain.from_iterable([glob(x) for x in sources]))
exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else () exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else ()
compression = storage_config.get('compression', None) compression = storage_config.get('compression', None)
compression_flags = ('--compression', compression) if compression else () compression_flags = ('--compression', compression) if compression else ()

View file

@ -189,7 +189,6 @@ def test_create_archive_with_globs():
source_directories='setup*', source_directories='setup*',
repository='repo', repository='repo',
command='attic', command='attic',
source_directories_glob=1,
) )

View file

@ -1,7 +1,7 @@
[location] [location]
# Space-separated list of source directories to backup. # Space-separated list of source directories to backup.
source_directories: /home /etc # Globs are expanded.
# source_directories_glob: 1 source_directories: /home /etc /var/log/syslog*
# For Borg only, you can specify to stay in same file system (do not cross # For Borg only, you can specify to stay in same file system (do not cross
# mount points). # mount points).