Added support for --one-file-system for Borg.
This commit is contained in:
parent
31482ee559
commit
049f9c8853
9 changed files with 39 additions and 4 deletions
1
AUTHORS
1
AUTHORS
|
@ -2,3 +2,4 @@ Dan Helfman <witten@torsion.org>: Main developer
|
|||
|
||||
Alexander Görtz: Python 3 compatibility
|
||||
Henning Schroeder: Copy editing
|
||||
Robin `ypid` Schneider: Support additional options of Borg
|
||||
|
|
3
NEWS
3
NEWS
|
@ -1,6 +1,7 @@
|
|||
0.1.8-dev
|
||||
0.1.8.dev0
|
||||
|
||||
* Fixed handling of repeated spaces in source_directories which resulted in backup up everything.
|
||||
* Added support for --one-file-system for Borg.
|
||||
|
||||
0.1.7
|
||||
|
||||
|
|
|
@ -7,7 +7,14 @@ from atticmatic.backends import shared
|
|||
|
||||
COMMAND = 'borg'
|
||||
CONFIG_FORMAT = (
|
||||
shared.CONFIG_FORMAT[0], # location
|
||||
Section_format(
|
||||
'location',
|
||||
(
|
||||
option('source_directories'),
|
||||
option('one_file_system', value_type=bool, required=False),
|
||||
option('repository'),
|
||||
),
|
||||
),
|
||||
Section_format(
|
||||
'storage',
|
||||
(
|
||||
|
|
|
@ -58,6 +58,7 @@ def initialize(storage_config, command):
|
|||
|
||||
def create_archive(
|
||||
excludes_filename, verbosity, storage_config, source_directories, repository, command,
|
||||
one_file_system=None,
|
||||
):
|
||||
'''
|
||||
Given an excludes filename (or None), a vebosity flag, a storage config dict, a space-separated
|
||||
|
@ -68,6 +69,7 @@ def create_archive(
|
|||
exclude_flags = ('--exclude-from', excludes_filename) if excludes_filename else ()
|
||||
compression = storage_config.get('compression', None)
|
||||
compression_flags = ('--compression', compression) if compression else ()
|
||||
one_file_system_flags = ('--one-file-system',) if one_file_system else ()
|
||||
verbosity_flags = {
|
||||
VERBOSITY_SOME: ('--stats',),
|
||||
VERBOSITY_LOTS: ('--verbose', '--stats'),
|
||||
|
@ -80,7 +82,8 @@ def create_archive(
|
|||
hostname=platform.node(),
|
||||
timestamp=datetime.now().isoformat(),
|
||||
),
|
||||
) + sources + exclude_flags + compression_flags + verbosity_flags
|
||||
) + sources + exclude_flags + compression_flags + one_file_system_flags + \
|
||||
verbosity_flags
|
||||
|
||||
subprocess.check_call(full_command)
|
||||
|
||||
|
|
|
@ -92,6 +92,7 @@ def parse_section_options(parser, section_format):
|
|||
type_getter = {
|
||||
str: parser.get,
|
||||
int: parser.getint,
|
||||
bool: parser.getboolean,
|
||||
}
|
||||
|
||||
return OrderedDict(
|
||||
|
|
|
@ -146,6 +146,22 @@ def test_create_archive_with_compression_should_call_attic_with_compression_para
|
|||
)
|
||||
|
||||
|
||||
def test_create_archive_with_one_file_system_should_call_attic_with_one_file_system_parameters():
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--one-file-system',))
|
||||
insert_platform_mock()
|
||||
insert_datetime_mock()
|
||||
|
||||
module.create_archive(
|
||||
excludes_filename='excludes',
|
||||
verbosity=None,
|
||||
storage_config={},
|
||||
source_directories='foo bar',
|
||||
repository='repo',
|
||||
command='attic',
|
||||
one_file_system=True,
|
||||
)
|
||||
|
||||
|
||||
BASE_PRUNE_FLAGS = (
|
||||
('--keep-daily', '1'),
|
||||
('--keep-weekly', '2'),
|
||||
|
|
|
@ -154,6 +154,7 @@ def test_parse_section_options_should_return_section_options():
|
|||
parser = flexmock()
|
||||
parser.should_receive('get').with_args('section', 'foo').and_return('value')
|
||||
parser.should_receive('getint').with_args('section', 'bar').and_return(1)
|
||||
parser.should_receive('getboolean').never()
|
||||
parser.should_receive('has_option').with_args('section', 'foo').and_return(True)
|
||||
parser.should_receive('has_option').with_args('section', 'bar').and_return(True)
|
||||
|
||||
|
@ -179,6 +180,7 @@ def test_parse_section_options_for_missing_section_should_return_empty_dict():
|
|||
parser = flexmock()
|
||||
parser.should_receive('get').never()
|
||||
parser.should_receive('getint').never()
|
||||
parser.should_receive('getboolean').never()
|
||||
parser.should_receive('has_option').with_args('section', 'foo').and_return(False)
|
||||
parser.should_receive('has_option').with_args('section', 'bar').and_return(False)
|
||||
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
# Space-separated list of source directories to backup.
|
||||
source_directories: /home /etc
|
||||
|
||||
# For Borg only, you can specify to stay in same file system (do not cross
|
||||
# mount points).
|
||||
#one_file_system: True
|
||||
|
||||
# Path to local or remote repository.
|
||||
repository: user@backupserver:sourcehostname.attic
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -1,7 +1,7 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
|
||||
VERSION = '0.1.7'
|
||||
VERSION = '0.1.8.dev0'
|
||||
|
||||
|
||||
setup(
|
||||
|
|
Loading…
Reference in a new issue