feat: add hourly and keep_last option
This commit is contained in:
parent
5c33ccf0b1
commit
19ac9e55e5
2 changed files with 11 additions and 2 deletions
|
@ -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
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue