From 06ad1dcb02c388b447badc5bb99bd4c44a2ec368 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Mon, 4 Sep 2017 16:03:15 +0200 Subject: [PATCH] fix(XoBackups#deltaCopyVm): do not always delete base (#599) Only when there are no VMs with the TAG_SOURCE_VM for this source VM. --- src/xo-mixins/backups.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/xo-mixins/backups.js b/src/xo-mixins/backups.js index 6eec441d9..30a6a8271 100644 --- a/src/xo-mixins/backups.js +++ b/src/xo-mixins/backups.js @@ -445,7 +445,9 @@ export default class { obj.$type === 'vm' && obj.other_config[TAG_SOURCE_VM] === uuid ) - const n = toRemove.length - retention + 1 // take into account the future copy + const { length } = toRemove + const deleteBase = length === 0 // old replications are not captured in toRemove + const n = length - retention + 1 // take into account the future copy toRemove = n > 0 ? sortBy(toRemove, _ => _.other_config[TAG_EXPORT_TIME]).slice(0, n) : undefined @@ -453,7 +455,7 @@ export default class { const promise = targetXapi.importDeltaVm( delta, { - deleteBase: toRemove === undefined, // old replications are not captured in toRemove + deleteBase, srId: targetSr.$id } )