diff --git a/backupbot.py b/backupbot.py index 0b0e0a6..34604a9 100755 --- a/backupbot.py +++ b/backupbot.py @@ -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()