mirror of https://github.com/borgbase/vorta
support borg prune --keep-within, fixes #6
This commit is contained in:
parent
7ae3f3222b
commit
514599a1e9
|
@ -196,6 +196,40 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="0,0,1">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>No matter what, keep all archives of the last:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="prune_keep_within">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>24H, 1d, 52w, 12m, 1y</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mountErrors">
|
||||
<property name="enabled">
|
||||
|
|
|
@ -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}')
|
||||
|
||||
|
|
|
@ -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)))
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue