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 2024-12-24 10:14:48 -08:00 committed by James Valleroy
parent 91270331cc
commit fd1d13f9af
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

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)