Ensure exit codes are propagated
This commit is contained in:
parent
ed46a472a1
commit
2a861b0519
|
@ -53,5 +53,7 @@ def run(image: str = None, command: str = None, volumes: dict = None,
|
||||||
|
|
||||||
|
|
||||||
container.reload()
|
container.reload()
|
||||||
logger.info("Container ExitCode %s", container.attrs['State']['ExitCode'])
|
logger.debug("Container ExitCode %s", container.attrs['State']['ExitCode'])
|
||||||
container.remove()
|
container.remove()
|
||||||
|
|
||||||
|
return container.attrs['State']['ExitCode']
|
||||||
|
|
|
@ -73,7 +73,7 @@ def backup(config, containers):
|
||||||
mounts = containers.generate_backup_mounts('/backup')
|
mounts = containers.generate_backup_mounts('/backup')
|
||||||
volumes.update(mounts)
|
volumes.update(mounts)
|
||||||
|
|
||||||
backup_runner.run(
|
result = backup_runner.run(
|
||||||
image=containers.this_container.image,
|
image=containers.this_container.image,
|
||||||
command='restic-volume-backup start-backup-process',
|
command='restic-volume-backup start-backup-process',
|
||||||
volumes=volumes,
|
volumes=volumes,
|
||||||
|
@ -84,6 +84,8 @@ def backup(config, containers):
|
||||||
"com.docker.compose.project": containers.this_container.project_name,
|
"com.docker.compose.project": containers.this_container.project_name,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
logger.info('Backup container exit code: %s', result)
|
||||||
|
# TODO: Alert
|
||||||
|
|
||||||
|
|
||||||
def start_backup_process(config, containers):
|
def start_backup_process(config, containers):
|
||||||
|
@ -100,14 +102,26 @@ def start_backup_process(config, containers):
|
||||||
logger.info("start-backup-process")
|
logger.info("start-backup-process")
|
||||||
|
|
||||||
# Back up volumes
|
# Back up volumes
|
||||||
restic.backup_files(config.repository, source='/backup')
|
try:
|
||||||
|
vol_result = restic.backup_files(config.repository, source='/backup')
|
||||||
|
logger.info('Volume backup exit code: %s', vol_result)
|
||||||
|
# TODO: Alert
|
||||||
|
except Exception as ex:
|
||||||
|
logger.error(ex)
|
||||||
|
# TODO: Alert
|
||||||
|
|
||||||
# back up databases
|
# back up databases
|
||||||
for container in containers.containers_for_backup():
|
for container in containers.containers_for_backup():
|
||||||
if container.database_backup_enabled:
|
if container.database_backup_enabled:
|
||||||
instance = container.instance
|
try:
|
||||||
logger.info('Backing up %s in service %s', instance.container_type, instance.service_name)
|
instance = container.instance
|
||||||
instance.backup()
|
logger.info('Backing up %s in service %s', instance.container_type, instance.service_name)
|
||||||
|
result = instance.backup()
|
||||||
|
logger.info('Exit code: %s', result)
|
||||||
|
# TODO: Alert
|
||||||
|
except Exception as ex:
|
||||||
|
logger.error(ex)
|
||||||
|
# TODO: Alert
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
|
|
@ -46,7 +46,7 @@ def backup_from_stdin(repository: str, filename: str, source_command: List[str])
|
||||||
|
|
||||||
# Ensure both processes exited with code 0
|
# Ensure both processes exited with code 0
|
||||||
source_exit, dest_exit = source_process.poll(), dest_process.poll()
|
source_exit, dest_exit = source_process.poll(), dest_process.poll()
|
||||||
return source_exit == 0 and dest_exit == 0
|
return 0 if (source_exit == 0 and dest_exit == 0) else 1
|
||||||
|
|
||||||
|
|
||||||
def snapshots(repository: str):
|
def snapshots(repository: str):
|
||||||
|
|
Loading…
Reference in New Issue