Support borg create --umask. (Merge PR from ypid.)
This commit is contained in:
parent
049f9c8853
commit
0012e0cdea
5 changed files with 23 additions and 1 deletions
1
NEWS
1
NEWS
|
@ -2,6 +2,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.
|
||||||
|
|
||||||
0.1.7
|
0.1.7
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ CONFIG_FORMAT = (
|
||||||
(
|
(
|
||||||
option('encryption_passphrase', required=False),
|
option('encryption_passphrase', required=False),
|
||||||
option('compression', required=False),
|
option('compression', required=False),
|
||||||
|
option('umask', required=False),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
shared.CONFIG_FORMAT[2], # retention
|
shared.CONFIG_FORMAT[2], # retention
|
||||||
|
@ -34,6 +35,7 @@ CONFIG_FORMAT = (
|
||||||
|
|
||||||
|
|
||||||
initialize = partial(shared.initialize, command=COMMAND)
|
initialize = partial(shared.initialize, command=COMMAND)
|
||||||
|
|
||||||
create_archive = partial(shared.create_archive, command=COMMAND)
|
create_archive = partial(shared.create_archive, command=COMMAND)
|
||||||
prune_archives = partial(shared.prune_archives, command=COMMAND)
|
prune_archives = partial(shared.prune_archives, command=COMMAND)
|
||||||
check_archives = partial(shared.check_archives, command=COMMAND)
|
check_archives = partial(shared.check_archives, command=COMMAND)
|
||||||
|
|
|
@ -69,6 +69,8 @@ def create_archive(
|
||||||
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 ()
|
||||||
|
umask = storage_config.get('umask', None)
|
||||||
|
umask_flags = ('--umask', str(umask)) if umask else ()
|
||||||
one_file_system_flags = ('--one-file-system',) if one_file_system else ()
|
one_file_system_flags = ('--one-file-system',) if one_file_system else ()
|
||||||
verbosity_flags = {
|
verbosity_flags = {
|
||||||
VERBOSITY_SOME: ('--stats',),
|
VERBOSITY_SOME: ('--stats',),
|
||||||
|
@ -83,7 +85,7 @@ def create_archive(
|
||||||
timestamp=datetime.now().isoformat(),
|
timestamp=datetime.now().isoformat(),
|
||||||
),
|
),
|
||||||
) + sources + exclude_flags + compression_flags + one_file_system_flags + \
|
) + sources + exclude_flags + compression_flags + one_file_system_flags + \
|
||||||
verbosity_flags
|
umask_flags + verbosity_flags
|
||||||
|
|
||||||
subprocess.check_call(full_command)
|
subprocess.check_call(full_command)
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,21 @@ def test_create_archive_with_one_file_system_should_call_attic_with_one_file_sys
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_create_archive_with_umask_should_call_attic_with_umask_parameters():
|
||||||
|
insert_subprocess_mock(CREATE_COMMAND + ('--umask', '740'))
|
||||||
|
insert_platform_mock()
|
||||||
|
insert_datetime_mock()
|
||||||
|
|
||||||
|
module.create_archive(
|
||||||
|
excludes_filename='excludes',
|
||||||
|
verbosity=None,
|
||||||
|
storage_config={'umask': 740},
|
||||||
|
source_directories='foo bar',
|
||||||
|
repository='repo',
|
||||||
|
command='attic',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
BASE_PRUNE_FLAGS = (
|
BASE_PRUNE_FLAGS = (
|
||||||
('--keep-daily', '1'),
|
('--keep-daily', '1'),
|
||||||
('--keep-weekly', '2'),
|
('--keep-weekly', '2'),
|
||||||
|
|
|
@ -17,6 +17,8 @@ repository: user@backupserver:sourcehostname.attic
|
||||||
# archives. See https://borgbackup.github.io/borgbackup/usage.html#borg-create
|
# archives. See https://borgbackup.github.io/borgbackup/usage.html#borg-create
|
||||||
# for details. Defaults to no compression.
|
# for details. Defaults to no compression.
|
||||||
#compression: lz4
|
#compression: lz4
|
||||||
|
# For Borg only, you can specify the umask to be used for borg create.
|
||||||
|
#umask: 0740
|
||||||
|
|
||||||
[retention]
|
[retention]
|
||||||
# Retention policy for how many backups to keep in each category. See
|
# Retention policy for how many backups to keep in each category. See
|
||||||
|
|
Loading…
Reference in a new issue