Support for Borg prune --umask option (#69).
This commit is contained in:
parent
219e287c6c
commit
cf846ab8ac
3 changed files with 38 additions and 15 deletions
4
NEWS
4
NEWS
|
@ -1,4 +1,4 @@
|
||||||
1.1.16.dev0
|
1.2.0
|
||||||
* #61: Support for Borg --list option via borgmatic command-line to list all archives.
|
* #61: Support for Borg --list option via borgmatic command-line to list all archives.
|
||||||
* #61: Support for Borg --info option via borgmatic command-line to display summary information.
|
* #61: Support for Borg --info option via borgmatic command-line to display summary information.
|
||||||
* #62: Update README to mention other ways of installing borgmatic.
|
* #62: Update README to mention other ways of installing borgmatic.
|
||||||
|
@ -9,6 +9,8 @@
|
||||||
* #60: Add "Persistent" flag to systemd timer example.
|
* #60: Add "Persistent" flag to systemd timer example.
|
||||||
* #63: Support for Borg --nobsdflags option to skip recording bsdflags (e.g. NODUMP, IMMUTABLE) in
|
* #63: Support for Borg --nobsdflags option to skip recording bsdflags (e.g. NODUMP, IMMUTABLE) in
|
||||||
archive.
|
archive.
|
||||||
|
* #69: Support for Borg prune --umask option using value of existing "umask" option in borgmatic's
|
||||||
|
storage configuration.
|
||||||
* Update tox.ini to only assume Python 3.x instead of Python 3.4 specifically.
|
* Update tox.ini to only assume Python 3.x instead of Python 3.4 specifically.
|
||||||
* Add ~/.config/borgmatic/config.yaml to default configuration path probing.
|
* Add ~/.config/borgmatic/config.yaml to default configuration path probing.
|
||||||
* Document how to develop on and contribute to borgmatic.
|
* Document how to develop on and contribute to borgmatic.
|
||||||
|
|
|
@ -39,23 +39,27 @@ def prune_archives(verbosity, dry_run, repository, storage_config, retention_con
|
||||||
retention config dict, prune Borg archives according to the retention policy specified in that
|
retention config dict, prune Borg archives according to the retention policy specified in that
|
||||||
configuration.
|
configuration.
|
||||||
'''
|
'''
|
||||||
remote_path_flags = ('--remote-path', remote_path) if remote_path else ()
|
umask = storage_config.get('umask', None)
|
||||||
lock_wait = storage_config.get('lock_wait', None)
|
lock_wait = storage_config.get('lock_wait', None)
|
||||||
lock_wait_flags = ('--lock-wait', str(lock_wait)) if lock_wait else ()
|
|
||||||
verbosity_flags = {
|
|
||||||
VERBOSITY_SOME: ('--info', '--stats',),
|
|
||||||
VERBOSITY_LOTS: ('--debug', '--stats', '--list'),
|
|
||||||
}.get(verbosity, ())
|
|
||||||
dry_run_flags = ('--dry-run',) if dry_run else ()
|
|
||||||
|
|
||||||
full_command = (
|
full_command = (
|
||||||
local_path, 'prune',
|
(
|
||||||
repository,
|
local_path, 'prune',
|
||||||
) + tuple(
|
repository,
|
||||||
element
|
) + tuple(
|
||||||
for pair in _make_prune_flags(retention_config)
|
element
|
||||||
for element in pair
|
for pair in _make_prune_flags(retention_config)
|
||||||
) + remote_path_flags + lock_wait_flags + verbosity_flags + dry_run_flags
|
for element in pair
|
||||||
|
)
|
||||||
|
+ (('--remote-path', remote_path) if remote_path else ())
|
||||||
|
+ (('--umask', str(umask)) if umask else ())
|
||||||
|
+ (('--lock-wait', str(lock_wait)) if lock_wait else ())
|
||||||
|
+ {
|
||||||
|
VERBOSITY_SOME: ('--info', '--stats',),
|
||||||
|
VERBOSITY_LOTS: ('--debug', '--stats', '--list'),
|
||||||
|
}.get(verbosity, ())
|
||||||
|
+ (('--dry-run',) if dry_run else ())
|
||||||
|
)
|
||||||
|
|
||||||
logger.debug(' '.join(full_command))
|
logger.debug(' '.join(full_command))
|
||||||
subprocess.check_call(full_command)
|
subprocess.check_call(full_command)
|
||||||
|
|
|
@ -153,6 +153,23 @@ def test_prune_archives_with_remote_path_calls_borg_with_remote_path_parameters(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_prune_archives_with_umask_calls_borg_with_umask_parameters():
|
||||||
|
storage_config = {'umask': '077'}
|
||||||
|
retention_config = flexmock()
|
||||||
|
flexmock(module).should_receive('_make_prune_flags').with_args(retention_config).and_return(
|
||||||
|
BASE_PRUNE_FLAGS,
|
||||||
|
)
|
||||||
|
insert_subprocess_mock(PRUNE_COMMAND + ('--umask', '077'))
|
||||||
|
|
||||||
|
module.prune_archives(
|
||||||
|
verbosity=None,
|
||||||
|
dry_run=False,
|
||||||
|
repository='repo',
|
||||||
|
storage_config=storage_config,
|
||||||
|
retention_config=retention_config,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
def test_prune_archives_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
||||||
storage_config = {'lock_wait': 5}
|
storage_config = {'lock_wait': 5}
|
||||||
retention_config = flexmock()
|
retention_config = flexmock()
|
||||||
|
|
Loading…
Reference in a new issue