diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ef3ac4a8..e49677357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Bug fixes - [Backup NG] Fix `Cannot read property 'uuid' of undefined` when a disk is removed from a VM to backup (PR [#3479](https://github.com/vatesfr/xen-orchestra/pull/3479)) +- [Backup NG] Fix unexpected full after failure, interruption or basic rolling snapshot (PR [#3485](https://github.com/vatesfr/xen-orchestra/pull/3485)) ### 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 a57a928ef..269ede7b8 100644 --- a/packages/xo-server/src/xo-mixins/backups-ng/index.js +++ b/packages/xo-server/src/xo-mixins/backups-ng/index.js @@ -12,6 +12,7 @@ import { basename, dirname } from 'path' import { NULL_REF } from 'xen-api' import { countBy, + findLast, flatMap, forOwn, groupBy, @@ -770,6 +771,7 @@ export default class BackupNg { }, xapi._updateObjectMapProperty(vm, 'other_config', { 'xo:backup:datetime': null, + 'xo:backup:exported': null, 'xo:backup:job': null, 'xo:backup:schedule': null, 'xo:backup:vm': null, @@ -890,7 +892,19 @@ export default class BackupNg { snapshot = await xapi.barrier(snapshot.$ref) - let baseSnapshot = mode === 'delta' ? last(snapshots) : undefined + let baseSnapshot + if (mode === 'delta') { + baseSnapshot = findLast( + snapshots, + _ => 'xo:backup:exported' in _.other_config + ) + + // JFT 2018-10-02: support previous snapshots which did not have this + // entry, can be removed after 2018-12. + if (baseSnapshot === undefined) { + baseSnapshot = last(snapshots) + } + } snapshots.push(snapshot) // snapshots to delete due to the snapshot retention settings @@ -1447,6 +1461,17 @@ export default class BackupNg { } else { throw new Error(`no exporter for backup mode ${mode}`) } + + await wrapTask( + { + logger, + message: 'set snapshot.other_config[xo:backup:exported]', + parentId: taskId, + }, + xapi._updateObjectMapProperty(snapshot, 'other_config', { + 'xo:backup:exported': 'true', + }) + ) } async _deleteDeltaVmBackups (