mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-03 17:36:05 +00:00
fix(vmbackups): fourth audit: missing incrementals, VM row changes
- Retention counts keep in ready backups only and also deletes the missing ones older than the oldest kept: an incremental whose files were lost no longer pins its chain on the target forever. - When another row takes a VM's place (a migration the destination's VM list recorded first, or a move found by a sync), its backups, schedule membership and today's schedule runs move with its owners: owners keep their backups, retention and restore over still see them, and the VM is not backed up twice that night.
This commit is contained in:
parent
bd5d42e65a
commit
57d4b61c6e
5 changed files with 71 additions and 17 deletions
|
|
@ -12,6 +12,7 @@ from instances.models import Instance, InstanceTombstone
|
|||
from logs.audit import write
|
||||
from operations import claims
|
||||
from operations.models import Claim
|
||||
from vmbackups.models import Backup, BackupRun
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
@ -86,7 +87,14 @@ def _log(inst, what):
|
|||
|
||||
|
||||
def move_ownership(source, target):
|
||||
"""Give target the owners and template flag of source; a user's rights are merged."""
|
||||
"""Give target the owners, template flag, backups and schedules of source; a user's rights are merged."""
|
||||
Backup.objects.filter(instance=source).update(instance=target)
|
||||
for policy in source.backup_policies.all():
|
||||
policy.instances.add(target)
|
||||
taken = set(BackupRun.objects.filter(instance=target).values_list("policy_id", "day"))
|
||||
for run in BackupRun.objects.filter(instance=source): # a schedule's run of the day: not taken twice
|
||||
if (run.policy_id, run.day) not in taken:
|
||||
BackupRun.objects.filter(pk=run.pk).update(instance=target)
|
||||
for ui in UserInstance.objects.filter(instance=source):
|
||||
existing = UserInstance.objects.filter(instance=target, user=ui.user).first()
|
||||
if existing is None:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue