From 19ac9e55e5f6bd1f5ccafe49a9d66adbe6a81cc4 Mon Sep 17 00:00:00 2001 From: Michael Reichenbach Date: Mon, 16 Nov 2020 11:31:19 +0100 Subject: [PATCH] feat: add hourly and keep_last option --- src/restic_compose_backup/config.py | 3 +++ src/restic_compose_backup/restic.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/restic_compose_backup/config.py b/src/restic_compose_backup/config.py index 8326a9b..1f484be 100644 --- a/src/restic_compose_backup/config.py +++ b/src/restic_compose_backup/config.py @@ -20,10 +20,13 @@ class Config: self.log_level = os.environ.get('LOG_LEVEL') # forget / keep + self.keep_last = os.environ.get('KEEP_LAST') or "7" + self.keep_hourly = os.environ.get('KEEP_HOURLY') or "24" self.keep_daily = os.environ.get('KEEP_DAILY') or "7" self.keep_weekly = os.environ.get('KEEP_WEEKLY') or "4" self.keep_monthly = os.environ.get('KEEP_MONTHLY') or "12" self.keep_yearly = os.environ.get('KEEP_YEARLY') or "3" + self.keep_tags = os.environ.get('KEEP_TAGS') or "keep" if check: self.check() diff --git a/src/restic_compose_backup/restic.py b/src/restic_compose_backup/restic.py index 5f79f90..fcc5c6b 100644 --- a/src/restic_compose_backup/restic.py +++ b/src/restic_compose_backup/restic.py @@ -75,11 +75,15 @@ def is_initialized(repository: str) -> bool: return commands.run(restic(repository, ["snapshots", '--last'])) == 0 -def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str): +def forget(repository: str, keeplast: str, hourly: str, daily: str, weekly: str, monthly: str, yearly: str, tags: str): return commands.run(restic(repository, [ 'forget', '--group-by', - 'paths', + 'paths,tags', + '-keep-last', + keeplast, + '--keep-hourly', + hourly '--keep-daily', daily, '--keep-weekly', @@ -88,6 +92,8 @@ def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str): monthly, '--keep-yearly', yearly, + '--keep-tag', + tags ]))