feat: separate cleanup from backup

This commit is contained in:
Michael Reichenbach 2020-11-16 11:32:40 +01:00
parent 19ac9e55e5
commit b0650c0425

View file

@ -237,12 +237,12 @@ def start_backup_process(config, containers):
logger.error('Exit code: %s', errors) logger.error('Exit code: %s', errors)
exit(1) exit(1)
# Only run cleanup if backup was successful # # Only run cleanup if backup was successful
result = cleanup(config, container) # result = cleanup(config, container)
logger.debug('cleanup exit code: %s', result) # logger.debug('cleanup exit code: %s', result)
if result != 0: # if result != 0:
logger.error('cleanup exit code: %s', result) # logger.error('cleanup exit code: %s', result)
exit(1) # exit(1)
# Test the repository for errors # Test the repository for errors
logger.info("Checking the repository for errors") logger.info("Checking the repository for errors")
@ -259,10 +259,13 @@ def cleanup(config, containers):
logger.info('Forget outdated snapshots') logger.info('Forget outdated snapshots')
forget_result = restic.forget( forget_result = restic.forget(
config.repository, config.repository,
config.keep_last,
config.keep_hourly,
config.keep_daily, config.keep_daily,
config.keep_weekly, config.keep_weekly,
config.keep_monthly, config.keep_monthly,
config.keep_yearly, config.keep_yearly,
config.keep_tags,
) )
logger.info('Prune stale data freeing storage space') logger.info('Prune stale data freeing storage space')
prune_result = restic.prune(config.repository) prune_result = restic.prune(config.repository)