Fix usage of RESTIC_REPOSITORY_FILE #51

This commit is contained in:
Moritz 2024-04-29 14:16:13 +02:00
parent 84d606fa80
commit 5582744073
1 changed files with 7 additions and 3 deletions

View File

@ -42,7 +42,7 @@ sys.excepthook = handle_exception
@click.option('-l', '--log', 'loglevel')
@click.option('-m', '--machine-logs', 'machine_logs', is_flag=True)
@click.option('service', '--host', '-h', envvar='SERVICE')
@click.option('repository', '--repo', '-r', envvar='RESTIC_REPOSITORY', required=True)
@click.option('repository', '--repo', '-r', envvar='RESTIC_REPOSITORY')
def cli(loglevel, service, repository, machine_logs):
global SERVICE
if service:
@ -66,9 +66,13 @@ def cli(loglevel, service, repository, machine_logs):
def init_repo():
repo = os.environ['RESTIC_REPOSITORY']
if repo:= os.environ['RESTIC_REPOSITORY_FILE']:
# RESTIC_REPOSITORY_FILE and RESTIC_REPOSITORY are mutually exclusive
del os.environ['RESTIC_REPOSITORY']
else:
repo = os.environ['RESTIC_REPOSITORY']
restic.repository = repo
logger.debug(f"set restic repository location: {repo}")
restic.repository = repo
restic.password_file = '/var/run/secrets/restic_password'
try:
restic.cat.config()