restic-compose-backup/src/restic_compose_backup/commands/cleanup.py

22 lines
693 B
Python
Raw Normal View History

2023-03-08 23:29:15 +01:00
from .base import BaseCommand
2023-03-09 01:42:27 +01:00
from restic_compose_backup import restic
2023-03-08 23:29:15 +01:00
class Command(BaseCommand):
"""Cleanup old snapshots"""
name = "cleanup"
def run(self):
2023-03-09 01:42:27 +01:00
"""Run forget / prune to minimize storage space"""
self.logger.info('Forget outdated snapshots')
forget_result = restic.forget(
self.config.repository,
self.config.keep_daily,
self.config.keep_weekly,
self.config.keep_monthly,
self.config.keep_yearly,
)
self.logger.info('Prune stale data freeing storage space')
prune_result = restic.prune(self.config.repository)
return forget_result and prune_result