diff --git a/CHANGELOG.md b/CHANGELOG.md index ac9e3d072..a77bef801 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ - [Legacy Backup] Fix error when restoring a backup - [Home] Fix `user.getAll` error when user is not admin [#3573](https://github.com/vatesfr/xen-orchestra/issues/3573) (PR [#3918](https://github.com/vatesfr/xen-orchestra/pull/3918)) - [Backup NG] Fix restore issue when a disk has grown [#3910](https://github.com/vatesfr/xen-orchestra/issues/3910) (PR [#3920](https://github.com/vatesfr/xen-orchestra/pull/3920)) +- [Backup NG] Delete _importing_ VMs due to interrupted CR/DR (PR [#3923](https://github.com/vatesfr/xen-orchestra/pull/3923)) ### Released packages diff --git a/packages/xo-server/src/xo-mixins/backups-ng/index.js b/packages/xo-server/src/xo-mixins/backups-ng/index.js index 131b4a3c3..b737a0761 100644 --- a/packages/xo-server/src/xo-mixins/backups-ng/index.js +++ b/packages/xo-server/src/xo-mixins/backups-ng/index.js @@ -183,7 +183,7 @@ const getJobCompression = ({ compression: c }) => const listReplicatedVms = ( xapi: Xapi, scheduleId: string, - srId: string, + srId?: string, vmUuid?: string ): Vm[] => { const { all } = xapi.objects @@ -918,6 +918,7 @@ export default class BackupNg { // - [x] possibility to (re-)run a single VM in a backup? // - [x] validate VHDs after exports and before imports, how? // - [x] check merge/transfert duration/size are what we want for delta + // - [x] delete interrupted *importing* VMs @defer async _backupVm( $defer: any, @@ -1236,6 +1237,14 @@ export default class BackupNg { const { $id: srId, xapi } = sr + // delete previous interrupted copies + ignoreErrors.call( + this._deleteVms( + xapi, + listReplicatedVms(xapi, scheduleId, undefined, vmUuid) + ) + ) + const oldVms = getOldEntries( copyRetention - 1, listReplicatedVms(xapi, scheduleId, srId, vmUuid) @@ -1572,6 +1581,14 @@ export default class BackupNg { const { $id: srId, xapi } = sr + // delete previous interrupted copies + ignoreErrors.call( + this._deleteVms( + xapi, + listReplicatedVms(xapi, scheduleId, undefined, vmUuid) + ) + ) + const oldVms = getOldEntries( copyRetention - 1, listReplicatedVms(xapi, scheduleId, srId, vmUuid)