@xen-orchestra/backups 0.29.2 → 0.29.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/RemoteAdapter.js
CHANGED
|
@@ -232,21 +232,23 @@ class RemoteAdapter {
|
|
|
232
232
|
return promise
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
#removeVmBackupsFromCache(backups) {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
235
|
+
async #removeVmBackupsFromCache(backups) {
|
|
236
|
+
await asyncEach(
|
|
237
|
+
Object.entries(
|
|
238
|
+
groupBy(
|
|
239
|
+
backups.map(_ => _._filename),
|
|
240
|
+
dirname
|
|
241
|
+
)
|
|
242
|
+
),
|
|
243
|
+
([dir, filenames]) =>
|
|
244
|
+
// will not reject
|
|
245
|
+
this._updateCache(dir + '/cache.json.gz', backups => {
|
|
246
|
+
for (const filename of filenames) {
|
|
247
|
+
debug('removing cache entry', { entry: filename })
|
|
248
|
+
delete backups[filename]
|
|
249
|
+
}
|
|
250
|
+
})
|
|
251
|
+
)
|
|
250
252
|
}
|
|
251
253
|
|
|
252
254
|
async deleteDeltaVmBackups(backups) {
|
|
@@ -255,7 +257,7 @@ class RemoteAdapter {
|
|
|
255
257
|
// this will delete the json, unused VHDs will be detected by `cleanVm`
|
|
256
258
|
await asyncMapSettled(backups, ({ _filename }) => handler.unlink(_filename))
|
|
257
259
|
|
|
258
|
-
this.#removeVmBackupsFromCache(backups)
|
|
260
|
+
await this.#removeVmBackupsFromCache(backups)
|
|
259
261
|
}
|
|
260
262
|
|
|
261
263
|
async deleteMetadataBackup(backupId) {
|
|
@@ -284,7 +286,7 @@ class RemoteAdapter {
|
|
|
284
286
|
Promise.all([handler.unlink(_filename), handler.unlink(resolveRelativeFromFile(_filename, xva))])
|
|
285
287
|
)
|
|
286
288
|
|
|
287
|
-
this.#removeVmBackupsFromCache(backups)
|
|
289
|
+
await this.#removeVmBackupsFromCache(backups)
|
|
288
290
|
}
|
|
289
291
|
|
|
290
292
|
deleteVmBackup(file) {
|
|
@@ -641,7 +643,7 @@ class RemoteAdapter {
|
|
|
641
643
|
})
|
|
642
644
|
|
|
643
645
|
// will not throw
|
|
644
|
-
this._updateCache(this.#getVmBackupsCache(vmUuid), backups => {
|
|
646
|
+
await this._updateCache(this.#getVmBackupsCache(vmUuid), backups => {
|
|
645
647
|
debug('adding cache entry', { entry: path })
|
|
646
648
|
backups[path] = {
|
|
647
649
|
...metadata,
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/vatesfr/xen-orchestra.git"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.29.
|
|
11
|
+
"version": "0.29.4",
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=14.6"
|
|
14
14
|
},
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"tmp": "^0.2.1"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@xen-orchestra/xapi": "^1.
|
|
55
|
+
"@xen-orchestra/xapi": "^1.6.0"
|
|
56
56
|
},
|
|
57
57
|
"license": "AGPL-3.0-or-later",
|
|
58
58
|
"author": {
|
|
@@ -11,7 +11,6 @@ const { dirname } = require('path')
|
|
|
11
11
|
|
|
12
12
|
const { formatFilenameDate } = require('../_filenameDate.js')
|
|
13
13
|
const { getOldEntries } = require('../_getOldEntries.js')
|
|
14
|
-
const { getVmBackupDir } = require('../_getVmBackupDir.js')
|
|
15
14
|
const { Task } = require('../Task.js')
|
|
16
15
|
|
|
17
16
|
const { MixinBackupWriter } = require('./_MixinBackupWriter.js')
|
|
@@ -29,8 +28,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
|
|
|
29
28
|
const backup = this._backup
|
|
30
29
|
const adapter = this._adapter
|
|
31
30
|
|
|
32
|
-
const
|
|
33
|
-
const vdisDir = `${backupDir}/vdis/${backup.job.id}`
|
|
31
|
+
const vdisDir = `${this._vmBackupDir}/vdis/${backup.job.id}`
|
|
34
32
|
|
|
35
33
|
await asyncMap(baseUuidToSrcVdi, async ([baseUuid, srcVdi]) => {
|
|
36
34
|
let found = false
|
|
@@ -143,7 +141,6 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
|
|
|
143
141
|
|
|
144
142
|
const jobId = job.id
|
|
145
143
|
const handler = adapter.handler
|
|
146
|
-
const backupDir = getVmBackupDir(vm.uuid)
|
|
147
144
|
|
|
148
145
|
// TODO: clean VM backup directory
|
|
149
146
|
|
|
@@ -177,7 +174,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
|
|
|
177
174
|
const { size } = await Task.run({ name: 'transfer' }, async () => {
|
|
178
175
|
await Promise.all(
|
|
179
176
|
map(deltaExport.vdis, async (vdi, id) => {
|
|
180
|
-
const path = `${
|
|
177
|
+
const path = `${this._vmBackupDir}/${vhds[id]}`
|
|
181
178
|
|
|
182
179
|
const isDelta = vdi.other_config['xo:base_delta'] !== undefined
|
|
183
180
|
let parentPath
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { formatFilenameDate } = require('../_filenameDate.js')
|
|
4
4
|
const { getOldEntries } = require('../_getOldEntries.js')
|
|
5
|
-
const { getVmBackupDir } = require('../_getVmBackupDir.js')
|
|
6
5
|
const { Task } = require('../Task.js')
|
|
7
6
|
|
|
8
7
|
const { MixinBackupWriter } = require('./_MixinBackupWriter.js')
|
|
@@ -34,7 +33,6 @@ exports.FullBackupWriter = class FullBackupWriter extends MixinBackupWriter(Abst
|
|
|
34
33
|
const { job, scheduleId, vm } = backup
|
|
35
34
|
|
|
36
35
|
const adapter = this._adapter
|
|
37
|
-
const backupDir = getVmBackupDir(vm.uuid)
|
|
38
36
|
|
|
39
37
|
// TODO: clean VM backup directory
|
|
40
38
|
|
|
@@ -47,7 +45,7 @@ exports.FullBackupWriter = class FullBackupWriter extends MixinBackupWriter(Abst
|
|
|
47
45
|
const basename = formatFilenameDate(timestamp)
|
|
48
46
|
|
|
49
47
|
const dataBasename = basename + '.xva'
|
|
50
|
-
const dataFilename =
|
|
48
|
+
const dataFilename = this._vmBackupDir + '/' + dataBasename
|
|
51
49
|
|
|
52
50
|
const metadata = {
|
|
53
51
|
jobId: job.id,
|
|
@@ -16,7 +16,6 @@ const { info, warn } = createLogger('xo:backups:MixinBackupWriter')
|
|
|
16
16
|
exports.MixinBackupWriter = (BaseClass = Object) =>
|
|
17
17
|
class MixinBackupWriter extends BaseClass {
|
|
18
18
|
#lock
|
|
19
|
-
#vmBackupDir
|
|
20
19
|
|
|
21
20
|
constructor({ remoteId, ...rest }) {
|
|
22
21
|
super(rest)
|
|
@@ -24,13 +23,13 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
|
|
|
24
23
|
this._adapter = rest.backup.remoteAdapters[remoteId]
|
|
25
24
|
this._remoteId = remoteId
|
|
26
25
|
|
|
27
|
-
this
|
|
26
|
+
this._vmBackupDir = getVmBackupDir(this._backup.vm.uuid)
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
async _cleanVm(options) {
|
|
31
30
|
try {
|
|
32
31
|
return await Task.run({ name: 'clean-vm' }, () => {
|
|
33
|
-
return this._adapter.cleanVm(this
|
|
32
|
+
return this._adapter.cleanVm(this._vmBackupDir, {
|
|
34
33
|
...options,
|
|
35
34
|
fixMetadata: true,
|
|
36
35
|
logInfo: info,
|
|
@@ -50,7 +49,7 @@ exports.MixinBackupWriter = (BaseClass = Object) =>
|
|
|
50
49
|
|
|
51
50
|
async beforeBackup() {
|
|
52
51
|
const { handler } = this._adapter
|
|
53
|
-
const vmBackupDir = this
|
|
52
|
+
const vmBackupDir = this._vmBackupDir
|
|
54
53
|
await handler.mktree(vmBackupDir)
|
|
55
54
|
this.#lock = await handler.lock(vmBackupDir)
|
|
56
55
|
}
|