fix(backups/MixinBackupWriter): clean VM dir after backup

Otherwise, it might trigger a chain reaction which will force all VDIs to be fully exported:

1. a single VDI chain is corrupted
2. it gets removed
3. the linked backups are removed
4. all other VDIs are now unused and are removed as well
5. all VDIs must now be fully exported
This commit is contained in:
Julien Fontanet
2021-04-28 13:20:56 +02:00
parent 5edd271975
commit 2e643fce28

View File

@@ -15,21 +15,18 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
}
async beforeBackup() {
const adapter = this._adapter
const vmBackupDir = getVmBackupDir(this._backup.vm.uuid)
this._lock = await this._adapter.handler.lock(getVmBackupDir(this._backup.vm.uuid))
}
async afterBackup() {
await this._lock.dispose()
try {
await adapter.cleanVm(getVmBackupDir(this._backup.vm.uuid), { remove: true, merge: true, onLog: warn })
await this._adapter.cleanVm(getVmBackupDir(this._backup.vm.uuid), { remove: true, merge: true, onLog: warn })
} catch (error) {
if (error?.code !== 'ENOENT') {
throw error
}
}
this._lock = await adapter.handler.lock(vmBackupDir)
}
async afterBackup() {
await this._lock.dispose()
}
}