backups: Use ISO timestamp for auto-naming archives

Closes: #1603.

- This introduces seconds and timezone in the name of the archive. When seconds
are not used in the name, taking backups too quickly on after the other fails as
the names clash.

Tests:

- Taking a backup works and creates the name in the expected ISO time format.

- Changing the timezone and restarting service creates timestamps in that
timezone.

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2024-12-30 08:34:04 -05:00
1 parent 91270331cc
commit fd1d13f9af
1 file changed
+5 -2
+5 -2
View File
@@ -130,8 +130,11 @@ class CreateArchiveView(SuccessMessageMixin, FormView):
if repository.flags.get('mountable'):
repository.mount()
name = form.cleaned_data['name'] or datetime.now().strftime(
'%Y-%m-%d:%H:%M')
name = form.cleaned_data['name']
if not name:
name = datetime.now().astimezone().replace(
microsecond=0).isoformat()
selected_apps = form.cleaned_data['selected_apps']
repository.create_archive(name, selected_apps)
return super().form_valid(form)