1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 09:26:03 +00:00

feat(vmbackups): restore, delete, retention, check and import know chains

An incremental backup is restored by copying its chain flat: every base's
disk file is checked first, as the backup's own, and a chain whose base's
row is gone is refused. A backup that a living backup builds on is not
deleted, by hand or by retention: retention deletes a chain only once all
of it is beyond keep, newest first; a failed backup holds no base. The
target check marks a backup missing when a base's file is gone. Reading a
target links each incremental backup to its base, read first, and leaves
one without its base unread. Restoring over the VM forgets its
checkpoints: its disks are replaced, and the next backup is full.
This commit is contained in:
catborise 2026-11-17 17:03:45 +03:00
parent 72e270a87e
commit d856ccca68
12 changed files with 555 additions and 391 deletions

View file

@ -85,6 +85,23 @@ class DeleteBackupTests(TransactionTestCase):
with self.assertRaisesMessage(OperationError, "being made"):
self.submit()
def test_a_backup_others_build_on_is_refused_until_they_go(self):
child = Backup.objects.create(target=self.target, instance=self.vm, vm_uuid=self.vm.uuid, vm_name="vm1",
compute_name="h1", state=Backup.READY, parent=self.backup)
with self.assertRaisesMessage(OperationError, "depend on this one"):
self.submit()
Backup.objects.filter(pk=child.pk).update(state=Backup.FAILED) # a failed one holds nothing
self.run_job(self.submit())
self.assertFalse(Backup.objects.filter(pk=self.backup.pk).exists())
def test_a_base_made_after_the_deletion_was_queued_is_kept(self):
op = self.submit()
Backup.objects.create(target=self.target, instance=self.vm, vm_uuid=self.vm.uuid, vm_name="vm1",
compute_name="h1", state=Backup.READY, parent=self.backup)
with self.assertRaisesMessage(OperationError, "depend on this one"):
self.run_job(op)
self.assertEqual(self.removed, [])
def test_a_target_no_compute_reaches_is_refused(self):
op = self.submit()
with patch("vmbackups.jobs.target_pool", side_effect=OperationError("Storage pool %(pool)s is gone", pool="b1")):