feat(backups/writers#beforeBackup): continue interrupted merges

This commit is contained in:
badrAZ 2021-04-30 17:55:09 +02:00 committed by Julien Fontanet
parent 5517305973
commit db75568905
2 changed files with 12 additions and 8 deletions

View File

@ -55,6 +55,11 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
})
}
async beforeBackup() {
await super.beforeBackup()
return this._cleanVm({ merge: true })
}
prepare({ isFull }) {
// create the task related to this export and ensure all methods are called in this context
const task = new Task({

View File

@ -14,6 +14,12 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
this._lock = undefined
}
_cleanVm(options) {
return this._adapter
.cleanVm(getVmBackupDir(this._backup.vm.uuid), { ...options, onLog: warn, lock: false })
.catch(warn)
}
async beforeBackup() {
const { handler } = this._adapter
const vmBackupDir = getVmBackupDir(this._backup.vm.uuid)
@ -22,14 +28,7 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
}
async afterBackup() {
await this._cleanVm({ remove: true, merge: true })
await this._lock.dispose()
try {
await this._adapter.cleanVm(getVmBackupDir(this._backup.vm.uuid), { remove: true, merge: true, onLog: warn })
} catch (error) {
if (error?.code !== 'ENOENT') {
throw error
}
}
}
}