fix(backups): dont ignore restored VMs

Fixes zammad#4794

Introduced by cf9f0da6e

Check that the `start` operation is blocked which is the case for replicated VMs but (should) not for restored backups.
This commit is contained in:
Julien Fontanet 2022-01-24 16:57:02 +01:00
parent 97d94b7952
commit aa27b3be64
3 changed files with 15 additions and 14 deletions

View File

@ -36,8 +36,9 @@ const forkDeltaExport = deltaExport =>
exports.VmBackup = class VmBackup {
constructor({ config, getSnapshotNameLabel, job, remoteAdapters, remotes, schedule, settings, srs, vm }) {
if (vm.other_config['xo:backup:job'] === job.id) {
// otherwise replicated VMs would be matched and replicated again and again
if (vm.other_config['xo:backup:job'] === job.id && 'start' in vm.blocked_operations) {
// don't match replicated VMs created by this very job otherwise they
// will be replicated again and again
throw new Error('cannot backup a VM created by this very job')
}

View File

@ -25,6 +25,7 @@
- [Backup] Delete S3 backups completely, even if there are more than 1000 files (PR [#6103](https://github.com/vatesfr/xen-orchestra/pull/6103))
- [Backup] Fix merge resuming (PR [#6099](https://github.com/vatesfr/xen-orchestra/pull/6099))
- [Plugin/Audit] Fix `key cannot be 'null' or 'undefined'` error when no audit log in the database [#6040](https://github.com/vatesfr/xen-orchestra/issues/6040) (PR [#6071](https://github.com/vatesfr/xen-orchestra/pull/6071))
- [Backup] Fix backuping restored VMs
### Packages to release

View File

@ -185,19 +185,18 @@ export default class BackupNg {
vmIds = Object.keys(
app.getObjects({
filter: createPredicate({
type: 'VM',
...vmsPattern,
filter: (() => {
const isMatchingVm = createPredicate({
type: 'VM',
...vmsPattern,
})
// don't match VMs created by this very job
//
// otherwise replicated VMs would be matched and replicated again and again
other: {
__not: {
'xo:backup:job': job.id,
},
},
}),
return obj =>
isMatchingVm(obj) &&
// don't match replicated VMs created by this very job otherwise
// they will be replicated again and again
!('start' in obj.blocked_operations && obj.other['xo:backup:job'] === job.id)
})(),
})
)
if (vmIds.length === 0) {