1
0
Fork 0
mirror of https://github.com/borgbase/vorta synced 2025-01-03 05:36:19 +00:00

Merge pull request #51 from ThomasWaldmann/keep-within

support borg prune --keep-within, fixes #6
This commit is contained in:
Manuel Riel 2018-11-26 13:15:12 +08:00 committed by GitHub
commit f59a531364
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 3 deletions

View file

@ -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">

View file

@ -34,6 +34,8 @@ def prepare(cls, profile):
'--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}')

View file

@ -9,7 +9,7 @@
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)))

View file

@ -40,9 +40,12 @@ def __init__(self, parent=None):
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)
@ -209,10 +212,11 @@ def umount_result(self, result):
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):