mirror of
https://github.com/borgbase/vorta
synced 2025-01-31 11:51:34 +00:00
Simplify default archive name (#861)
This commit is contained in:
parent
3cf2ac0c41
commit
355ddda0ec
4 changed files with 9 additions and 7 deletions
|
@ -425,7 +425,7 @@
|
||||||
<string>Available variables: hostname, profile_id, profile_slug, now, utc_now, user</string>
|
<string>Available variables: hostname, profile_id, profile_slug, now, utc_now, user</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="placeholderText">
|
<property name="placeholderText">
|
||||||
<string>{hostname}-{profile_slug}-{now:%Y-%m-%dT%H:%M:%S}</string>
|
<string>{hostname}-{profile_slug}-{now:%Y-%m-%d-%H%M%S}</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
|
@ -22,7 +22,6 @@ def prepare(cls, profile):
|
||||||
ret['ok'] = False # Set back to false, so we can do our own checks here.
|
ret['ok'] = False # Set back to false, so we can do our own checks here.
|
||||||
|
|
||||||
cmd = ['borg', 'prune', '--list', '--info', '--log-json']
|
cmd = ['borg', 'prune', '--list', '--info', '--log-json']
|
||||||
formatted_prune_prefix = format_archive_name(profile, profile.prune_prefix)
|
|
||||||
|
|
||||||
pruning_opts = [
|
pruning_opts = [
|
||||||
'--keep-hourly', str(profile.prune_hour),
|
'--keep-hourly', str(profile.prune_hour),
|
||||||
|
@ -30,8 +29,12 @@ def prepare(cls, profile):
|
||||||
'--keep-weekly', str(profile.prune_week),
|
'--keep-weekly', str(profile.prune_week),
|
||||||
'--keep-monthly', str(profile.prune_month),
|
'--keep-monthly', str(profile.prune_month),
|
||||||
'--keep-yearly', str(profile.prune_year),
|
'--keep-yearly', str(profile.prune_year),
|
||||||
'--prefix', formatted_prune_prefix
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if profile.prune_prefix:
|
||||||
|
formatted_prune_prefix = format_archive_name(profile, profile.prune_prefix)
|
||||||
|
pruning_opts += ['--prefix', formatted_prune_prefix]
|
||||||
|
|
||||||
if profile.prune_keep_within:
|
if profile.prune_keep_within:
|
||||||
pruning_opts += ['--keep-within', profile.prune_keep_within]
|
pruning_opts += ['--keep-within', profile.prune_keep_within]
|
||||||
cmd += pruning_opts
|
cmd += pruning_opts
|
||||||
|
|
|
@ -87,8 +87,8 @@ class BackupProfileModel(pw.Model):
|
||||||
prune_month = pw.IntegerField(default=6)
|
prune_month = pw.IntegerField(default=6)
|
||||||
prune_year = pw.IntegerField(default=2)
|
prune_year = pw.IntegerField(default=2)
|
||||||
prune_keep_within = pw.CharField(default='10H', null=True)
|
prune_keep_within = pw.CharField(default='10H', null=True)
|
||||||
new_archive_name = pw.CharField(default="{hostname}-{profile_slug}-{now:%Y-%m-%dT%H:%M:%S}")
|
new_archive_name = pw.CharField(default="{hostname}-{now:%Y-%m-%d-%H%M%S}")
|
||||||
prune_prefix = pw.CharField(default="{hostname}-{profile_slug}-")
|
prune_prefix = pw.CharField(default="{hostname}-")
|
||||||
pre_backup_cmd = pw.CharField(default='')
|
pre_backup_cmd = pw.CharField(default='')
|
||||||
post_backup_cmd = pw.CharField(default='')
|
post_backup_cmd = pw.CharField(default='')
|
||||||
dont_run_on_metered_networks = pw.BooleanField(default=True)
|
dont_run_on_metered_networks = pw.BooleanField(default=True)
|
||||||
|
|
|
@ -270,8 +270,7 @@ def uses_dark_mode():
|
||||||
|
|
||||||
def format_archive_name(profile, archive_name_tpl):
|
def format_archive_name(profile, archive_name_tpl):
|
||||||
"""
|
"""
|
||||||
Generate an archive name. Default:
|
Generate an archive name. Default set in models.BackupProfileModel
|
||||||
{hostname}-{profile_slug}-{now:%Y-%m-%dT%H:%M:%S}
|
|
||||||
"""
|
"""
|
||||||
available_vars = {
|
available_vars = {
|
||||||
'hostname': platform.node(),
|
'hostname': platform.node(),
|
||||||
|
|
Loading…
Reference in a new issue