Simplify default archive name (#861)

This commit is contained in:
Manu 2021-02-18 09:52:59 +08:00 committed by GitHub
parent 3cf2ac0c41
commit 355ddda0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View File

@ -425,7 +425,7 @@
<string>Available variables: hostname, profile_id, profile_slug, now, utc_now, user</string>
</property>
<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>
</widget>
</item>

View File

@ -22,7 +22,6 @@ class BorgPruneThread(BorgThread):
ret['ok'] = False # Set back to false, so we can do our own checks here.
cmd = ['borg', 'prune', '--list', '--info', '--log-json']
formatted_prune_prefix = format_archive_name(profile, profile.prune_prefix)
pruning_opts = [
'--keep-hourly', str(profile.prune_hour),
@ -30,8 +29,12 @@ class BorgPruneThread(BorgThread):
'--keep-weekly', str(profile.prune_week),
'--keep-monthly', str(profile.prune_month),
'--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:
pruning_opts += ['--keep-within', profile.prune_keep_within]
cmd += pruning_opts

View File

@ -87,8 +87,8 @@ class BackupProfileModel(pw.Model):
prune_month = pw.IntegerField(default=6)
prune_year = pw.IntegerField(default=2)
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}")
prune_prefix = pw.CharField(default="{hostname}-{profile_slug}-")
new_archive_name = pw.CharField(default="{hostname}-{now:%Y-%m-%d-%H%M%S}")
prune_prefix = pw.CharField(default="{hostname}-")
pre_backup_cmd = pw.CharField(default='')
post_backup_cmd = pw.CharField(default='')
dont_run_on_metered_networks = pw.BooleanField(default=True)

View File

@ -270,8 +270,7 @@ def uses_dark_mode():
def format_archive_name(profile, archive_name_tpl):
"""
Generate an archive name. Default:
{hostname}-{profile_slug}-{now:%Y-%m-%dT%H:%M:%S}
Generate an archive name. Default set in models.BackupProfileModel
"""
available_vars = {
'hostname': platform.node(),