Support for various Borg directory environment variables (#153).
This commit is contained in:
parent
223f803e87
commit
1cf0e1bd84
5 changed files with 48 additions and 15 deletions
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
||||||
|
1.3.5.dev0
|
||||||
|
* #153: Support for various Borg directory environment variables (BORG_CONFIG_DIR, BORG_CACHE_DIR,
|
||||||
|
etc.) via options in borgmatic's storage configuration.
|
||||||
|
|
||||||
1.3.4
|
1.3.4
|
||||||
* Part of #125: Color borgmatic (but not Borg) output when using an interactive terminal.
|
* Part of #125: Color borgmatic (but not Borg) output when using an interactive terminal.
|
||||||
* #166: Run tests for all installed versions of Python.
|
* #166: Run tests for all installed versions of Python.
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
OPTION_TO_ENVIRONMENT_VARIABLE = {
|
||||||
|
'borg_base_directory': 'BORG_BASE_DIR',
|
||||||
|
'borg_config_directory': 'BORG_CONFIG_DIR',
|
||||||
|
'borg_cache_directory': 'BORG_CACHE_DIR',
|
||||||
|
'borg_security_directory': 'BORG_SECURITY_DIR',
|
||||||
|
'borg_keys_directory': 'BORG_KEYS_DIR',
|
||||||
|
'encryption_passcommand': 'BORG_PASSCOMMAND',
|
||||||
|
'encryption_passphrase': 'BORG_PASSPHRASE',
|
||||||
|
'ssh_command': 'BORG_RSH',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def initialize(storage_config):
|
def initialize(storage_config):
|
||||||
passcommand = storage_config.get('encryption_passcommand')
|
for option_name, environment_variable_name in OPTION_TO_ENVIRONMENT_VARIABLE.items():
|
||||||
if passcommand:
|
value = storage_config.get(option_name)
|
||||||
os.environ['BORG_PASSCOMMAND'] = passcommand
|
if value:
|
||||||
|
os.environ[environment_variable_name] = value
|
||||||
passphrase = storage_config.get('encryption_passphrase')
|
|
||||||
if passphrase:
|
|
||||||
os.environ['BORG_PASSPHRASE'] = passphrase
|
|
||||||
|
|
||||||
ssh_command = storage_config.get('ssh_command')
|
|
||||||
if ssh_command:
|
|
||||||
os.environ['BORG_RSH'] = ssh_command
|
|
||||||
|
|
|
@ -168,6 +168,32 @@ map:
|
||||||
Command to use instead of "ssh". This can be used to specify ssh options.
|
Command to use instead of "ssh". This can be used to specify ssh options.
|
||||||
Defaults to not set.
|
Defaults to not set.
|
||||||
example: ssh -i /path/to/private/key
|
example: ssh -i /path/to/private/key
|
||||||
|
borg_base_directory:
|
||||||
|
type: scalar
|
||||||
|
desc: |
|
||||||
|
Base path used for various Borg directories. Defaults to $HOME, ~$USER, or ~.
|
||||||
|
See https://borgbackup.readthedocs.io/en/stable/usage/general.html#environment-variables for details.
|
||||||
|
example: /path/to/base
|
||||||
|
borg_config_directory:
|
||||||
|
type: scalar
|
||||||
|
desc: |
|
||||||
|
Path for Borg configuration files. Defaults to $borg_base_directory/.config/borg
|
||||||
|
example: /path/to/base/config
|
||||||
|
borg_cache_directory:
|
||||||
|
type: scalar
|
||||||
|
desc: |
|
||||||
|
Path for Borg cache files. Defaults to $borg_base_directory/.cache/borg
|
||||||
|
example: /path/to/base/cache
|
||||||
|
borg_security_directory:
|
||||||
|
type: scalar
|
||||||
|
desc: |
|
||||||
|
Path for Borg security and encryption nonce files. Defaults to $borg_base_directory/.config/borg/security
|
||||||
|
example: /path/to/base/config/security
|
||||||
|
borg_keys_directory:
|
||||||
|
type: scalar
|
||||||
|
desc: |
|
||||||
|
Path for Borg encryption key files. Defaults to $borg_base_directory/.config/borg/keys
|
||||||
|
example: /path/to/base/config/keys
|
||||||
umask:
|
umask:
|
||||||
type: scalar
|
type: scalar
|
||||||
desc: Umask to be used for borg create. Defaults to 0077.
|
desc: Umask to be used for borg create. Defaults to 0077.
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
||||||
from setuptools import find_packages, setup
|
from setuptools import find_packages, setup
|
||||||
|
|
||||||
VERSION = '1.3.4'
|
VERSION = '1.3.5.dev0'
|
||||||
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
|
|
|
@ -42,8 +42,7 @@ def test_initialize_without_configuration_should_not_set_environment():
|
||||||
try:
|
try:
|
||||||
os.environ = {}
|
os.environ = {}
|
||||||
module.initialize({})
|
module.initialize({})
|
||||||
assert os.environ.get('BORG_PASSCOMMAND') is None
|
|
||||||
assert os.environ.get('BORG_PASSPHRASE') is None
|
assert sum(1 for key in os.environ.keys() if key.startswith('BORG_')) == 0
|
||||||
assert os.environ.get('BORG_RSH') is None
|
|
||||||
finally:
|
finally:
|
||||||
os.environ = orig_environ
|
os.environ = orig_environ
|
||||||
|
|
Loading…
Reference in a new issue