mirror of
https://github.com/ZettaIO/restic-compose-backup.git
synced 2025-12-14 09:52:21 +00:00
feat: add hourly and keep_last option
This commit is contained in:
@@ -20,10 +20,13 @@ class Config:
|
|||||||
self.log_level = os.environ.get('LOG_LEVEL')
|
self.log_level = os.environ.get('LOG_LEVEL')
|
||||||
|
|
||||||
# forget / keep
|
# 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_daily = os.environ.get('KEEP_DAILY') or "7"
|
||||||
self.keep_weekly = os.environ.get('KEEP_WEEKLY') or "4"
|
self.keep_weekly = os.environ.get('KEEP_WEEKLY') or "4"
|
||||||
self.keep_monthly = os.environ.get('KEEP_MONTHLY') or "12"
|
self.keep_monthly = os.environ.get('KEEP_MONTHLY') or "12"
|
||||||
self.keep_yearly = os.environ.get('KEEP_YEARLY') or "3"
|
self.keep_yearly = os.environ.get('KEEP_YEARLY') or "3"
|
||||||
|
self.keep_tags = os.environ.get('KEEP_TAGS') or "keep"
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
self.check()
|
self.check()
|
||||||
|
|||||||
@@ -75,11 +75,15 @@ def is_initialized(repository: str) -> bool:
|
|||||||
return commands.run(restic(repository, ["snapshots", '--last'])) == 0
|
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, [
|
return commands.run(restic(repository, [
|
||||||
'forget',
|
'forget',
|
||||||
'--group-by',
|
'--group-by',
|
||||||
'paths',
|
'paths,tags',
|
||||||
|
'-keep-last',
|
||||||
|
keeplast,
|
||||||
|
'--keep-hourly',
|
||||||
|
hourly
|
||||||
'--keep-daily',
|
'--keep-daily',
|
||||||
daily,
|
daily,
|
||||||
'--keep-weekly',
|
'--keep-weekly',
|
||||||
@@ -88,6 +92,8 @@ def forget(repository: str, daily: str, weekly: str, monthly: str, yearly: str):
|
|||||||
monthly,
|
monthly,
|
||||||
'--keep-yearly',
|
'--keep-yearly',
|
||||||
yearly,
|
yearly,
|
||||||
|
'--keep-tag',
|
||||||
|
tags
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user