feat(xo-server/backupNg): remove incomplete XVAs (#3215)

Fixes #3159
This commit is contained in:
Julien Fontanet 2018-07-20 15:29:38 +02:00 committed by GitHub
parent f00be23e02
commit d99555a4a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -11,6 +11,7 @@
- [Backup Reports] Report not sent if reportWhen failure and at least a VM is successfull [#3181](https://github.com/vatesfr/xen-orchestra/issues/3181) (PR [#3185](https://github.com/vatesfr/xen-orchestra/pull/3185)) - [Backup Reports] Report not sent if reportWhen failure and at least a VM is successfull [#3181](https://github.com/vatesfr/xen-orchestra/issues/3181) (PR [#3185](https://github.com/vatesfr/xen-orchestra/pull/3185))
- [Backup NG] Correctly migrate report setting from legacy jobs [#3180](https://github.com/vatesfr/xen-orchestra/issues/3180) (PR [#3206](https://github.com/vatesfr/xen-orchestra/pull/3206)) - [Backup NG] Correctly migrate report setting from legacy jobs [#3180](https://github.com/vatesfr/xen-orchestra/issues/3180) (PR [#3206](https://github.com/vatesfr/xen-orchestra/pull/3206))
- [Backup NG] remove incomplete XVA files [#3159](https://github.com/vatesfr/xen-orchestra/issues/3159) (PR [#3215](https://github.com/vatesfr/xen-orchestra/pull/3215))
### Released packages ### Released packages

View File

@ -155,6 +155,7 @@ const getVmBackupDir = (uuid: string) => `${BACKUP_DIR}/${uuid}`
const isHiddenFile = (filename: string) => filename[0] === '.' const isHiddenFile = (filename: string) => filename[0] === '.'
const isMetadataFile = (filename: string) => filename.endsWith('.json') const isMetadataFile = (filename: string) => filename.endsWith('.json')
const isVhd = (filename: string) => filename.endsWith('.vhd') const isVhd = (filename: string) => filename.endsWith('.vhd')
const isXva = (filename: string) => filename.endsWith('.xva')
const listReplicatedVms = ( const listReplicatedVms = (
xapi: Xapi, xapi: Xapi,
@ -966,6 +967,16 @@ export default class BackupNg {
async (taskId, { handler, id: remoteId }) => { async (taskId, { handler, id: remoteId }) => {
const fork = forkExport() const fork = forkExport()
// remove incomplete XVAs
await asyncMap(
handler.list(vmDir, {
filter: filename =>
isHiddenFile(filename) && isXva(filename),
prependDir: true,
}),
file => handler.unlink(file)
)::ignoreErrors()
const oldBackups: MetadataFull[] = (getOldEntries( const oldBackups: MetadataFull[] = (getOldEntries(
exportRetention, exportRetention,
await this._listVmBackups( await this._listVmBackups(