diff --git a/backupbot.py b/backupbot.py index af60e12..e131e54 100755 --- a/backupbot.py +++ b/backupbot.py @@ -18,7 +18,8 @@ SERVICE = None @click.group() @click.option('-l', '--log', 'loglevel') @click.option('service', '--host', '-h', envvar='SERVICE') -def cli(loglevel, service): +@click.option('repository', '--repo', '-r', envvar='RESTIC_REPO', required=True) +def cli(loglevel, service, repository): global SERVICE if service: SERVICE = service.replace('.','_') @@ -27,12 +28,12 @@ def cli(loglevel, service): if not isinstance(numeric_level, int): raise ValueError('Invalid log level: %s' % loglevel) logging.basicConfig(level=numeric_level) - init_repo() - - -def init_repo(): export_secrets() - restic.repository = os.environ['RESTIC_REPO'] + init_repo(repository) + + +def init_repo(repository): + restic.repository = repository restic.password_file = '/var/run/secrets/restic_password' try: restic.cat.config() @@ -94,7 +95,7 @@ def run_commands(commands): logging.info(f"run command in {container.name}") logging.info(command) if result.exit_code: - logging.error(result.output.decode()) + logging.error(f"Failed to run command {command} in {container.name}: {result.output.decode()}") else: logging.info(result.output.decode())