diff --git a/src/vorta/assets/UI/archivetab.ui b/src/vorta/assets/UI/archivetab.ui
index 3b4c46a6..259b879a 100644
--- a/src/vorta/assets/UI/archivetab.ui
+++ b/src/vorta/assets/UI/archivetab.ui
@@ -196,6 +196,40 @@
+ -
+
+
-
+
+
+ No matter what, keep all archives of the last:
+
+
+
+ -
+
+
+
+
+
+ 24H, 1d, 52w, 12m, 1y
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
-
diff --git a/src/vorta/borg/prune.py b/src/vorta/borg/prune.py
index 7cbc3048..235b76a9 100644
--- a/src/vorta/borg/prune.py
+++ b/src/vorta/borg/prune.py
@@ -34,6 +34,8 @@ class BorgPruneThread(BorgThread):
'--keep-yearly', str(profile.prune_year),
'--prefix', f'{platform.node()}-'
]
+ if profile.prune_keep_within:
+ pruning_opts += ['--keep-within', profile.prune_keep_within]
cmd += pruning_opts
cmd.append(f'{profile.repo.url}')
diff --git a/src/vorta/models.py b/src/vorta/models.py
index 68b168ca..7914fd35 100644
--- a/src/vorta/models.py
+++ b/src/vorta/models.py
@@ -9,7 +9,7 @@ import json
from datetime import datetime, timedelta
from playhouse.migrate import SqliteMigrator, migrate
-SCHEMA_VERSION = 7
+SCHEMA_VERSION = 8
db = pw.Proxy()
@@ -77,6 +77,7 @@ class BackupProfileModel(pw.Model):
prune_week = pw.IntegerField(default=4)
prune_month = pw.IntegerField(default=6)
prune_year = pw.IntegerField(default=2)
+ prune_keep_within = pw.CharField(default='10H', null=True)
def refresh(self):
return type(self).get(self._pk_expr())
@@ -215,3 +216,9 @@ def init_db(con):
migrator.drop_column(EventLogModel._meta.table_name, 'profile_id'),
migrator.add_column(EventLogModel._meta.table_name, 'profile', pw.CharField(null=True))
)
+
+ if current_schema.version < 8:
+ _apply_schema_update(
+ current_schema, 8,
+ migrator.add_column(BackupProfileModel._meta.table_name,
+ 'prune_keep_within', pw.CharField(null=True)))
diff --git a/src/vorta/views/archive_tab.py b/src/vorta/views/archive_tab.py
index 3eba2980..eb81cccf 100644
--- a/src/vorta/views/archive_tab.py
+++ b/src/vorta/views/archive_tab.py
@@ -40,9 +40,12 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
self.archiveTable.setAlternatingRowColors(True)
# Populate pruning options from database
+ profile = self.profile()
for i in self.prune_intervals:
- getattr(self, f'prune_{i}').setValue(getattr(self.profile(), f'prune_{i}'))
+ getattr(self, f'prune_{i}').setValue(getattr(profile, f'prune_{i}'))
getattr(self, f'prune_{i}').valueChanged.connect(self.save_prune_setting)
+ self.prune_keep_within.setText(profile.prune_keep_within)
+ self.prune_keep_within.editingFinished.connect(self.save_prune_setting)
self.mountButton.clicked.connect(self.mount_action)
self.listButton.clicked.connect(self.list_action)
@@ -198,10 +201,11 @@ class ArchiveTab(ArchiveTabBase, ArchiveTabUI, BackupProfileMixin):
self.mountButton.clicked.connect(self.mount_action)
self.mount_point = None
- def save_prune_setting(self, new_value):
+ def save_prune_setting(self, new_value=None):
profile = self.profile()
for i in self.prune_intervals:
setattr(profile, f'prune_{i}', getattr(self, f'prune_{i}').value())
+ profile.prune_keep_within = self.prune_keep_within.text()
profile.save()
def extract_action(self):