mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +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:
parent
72e270a87e
commit
d856ccca68
12 changed files with 555 additions and 391 deletions
|
|
@ -140,7 +140,8 @@ def _attempt_key(base):
|
|||
|
||||
|
||||
def retain():
|
||||
"""Each schedule's ready backups of a VM beyond keep, oldest first: one
|
||||
"""Each schedule's ready backups of a VM beyond keep that no backup
|
||||
builds on, oldest first: one
|
||||
deletion a target at a time (its claim admits one), the rest at the next
|
||||
passes. Backups by hand and those of removed VMs are left alone."""
|
||||
tried = set()
|
||||
|
|
@ -153,12 +154,14 @@ def retain():
|
|||
for backup in ready:
|
||||
groups.setdefault(backup.instance_id, []).append(backup)
|
||||
for rows in groups.values():
|
||||
if len(rows) > policy.keep:
|
||||
# a chain goes when all of it is beyond keep, newest first: only a backup nothing builds on is deleted
|
||||
beyond = [b for b in rows[policy.keep:] if not b.depended_on()]
|
||||
if beyond:
|
||||
tried.add(policy.target_id)
|
||||
if (key := _attempt_key(f"rt-{rows[-1].uuid.hex}")) is None:
|
||||
if (key := _attempt_key(f"rt-{beyond[-1].uuid.hex}")) is None:
|
||||
break
|
||||
try:
|
||||
jobs.submit("backup.delete", policy.owner, {"backup": str(rows[-1].uuid), "retention": policy.pk},
|
||||
jobs.submit("backup.delete", policy.owner, {"backup": str(beyond[-1].uuid), "retention": policy.pk},
|
||||
key)
|
||||
except Exception as err: # busy, or refused: the next pass looks again
|
||||
logger.info("schedule %s: retention waits: %s", policy.name, safe_text(err))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue