@xen-orchestra/backups 0.28.1 → 0.29.0
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/Backup.js +1 -0
- package/RemoteAdapter.js +2 -2
- package/package.json +5 -4
- package/writers/DeltaBackupWriter.js +20 -1
package/Backup.js
CHANGED
package/RemoteAdapter.js
CHANGED
|
@@ -659,9 +659,8 @@ class RemoteAdapter {
|
|
|
659
659
|
return path
|
|
660
660
|
}
|
|
661
661
|
|
|
662
|
-
async writeVhd(path, input, { checksum = true, validator = noop, writeBlockConcurrency } = {}) {
|
|
662
|
+
async writeVhd(path, input, { checksum = true, validator = noop, writeBlockConcurrency, nbdClient } = {}) {
|
|
663
663
|
const handler = this._handler
|
|
664
|
-
|
|
665
664
|
if (this.#useVhdDirectory()) {
|
|
666
665
|
const dataPath = `${dirname(path)}/data/${uuidv4()}.vhd`
|
|
667
666
|
await createVhdDirectoryFromStream(handler, dataPath, input, {
|
|
@@ -671,6 +670,7 @@ class RemoteAdapter {
|
|
|
671
670
|
await input.task
|
|
672
671
|
return validator.apply(this, arguments)
|
|
673
672
|
},
|
|
673
|
+
nbdClient,
|
|
674
674
|
})
|
|
675
675
|
await VhdAbstract.createAlias(handler, path, dataPath)
|
|
676
676
|
} else {
|
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.
|
|
11
|
+
"version": "0.29.0",
|
|
12
12
|
"engines": {
|
|
13
13
|
"node": ">=14.6"
|
|
14
14
|
},
|
|
@@ -22,9 +22,10 @@
|
|
|
22
22
|
"@vates/decorate-with": "^2.0.0",
|
|
23
23
|
"@vates/disposable": "^0.1.2",
|
|
24
24
|
"@vates/fuse-vhd": "^1.0.0",
|
|
25
|
+
"@vates/nbd-client": "*",
|
|
25
26
|
"@vates/parse-duration": "^0.1.1",
|
|
26
27
|
"@xen-orchestra/async-map": "^0.1.2",
|
|
27
|
-
"@xen-orchestra/fs": "^3.
|
|
28
|
+
"@xen-orchestra/fs": "^3.2.0",
|
|
28
29
|
"@xen-orchestra/log": "^0.4.0",
|
|
29
30
|
"@xen-orchestra/template": "^0.1.0",
|
|
30
31
|
"compare-versions": "^5.0.1",
|
|
@@ -40,7 +41,7 @@
|
|
|
40
41
|
"promise-toolbox": "^0.21.0",
|
|
41
42
|
"proper-lockfile": "^4.1.2",
|
|
42
43
|
"uuid": "^9.0.0",
|
|
43
|
-
"vhd-lib": "^4.1.
|
|
44
|
+
"vhd-lib": "^4.1.1",
|
|
44
45
|
"yazl": "^2.5.1"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
@@ -48,7 +49,7 @@
|
|
|
48
49
|
"tmp": "^0.2.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
|
-
"@xen-orchestra/xapi": "^1.5.
|
|
52
|
+
"@xen-orchestra/xapi": "^1.5.2"
|
|
52
53
|
},
|
|
53
54
|
"license": "AGPL-3.0-or-later",
|
|
54
55
|
"author": {
|
|
@@ -19,8 +19,9 @@ const { AbstractDeltaWriter } = require('./_AbstractDeltaWriter.js')
|
|
|
19
19
|
const { checkVhd } = require('./_checkVhd.js')
|
|
20
20
|
const { packUuid } = require('./_packUuid.js')
|
|
21
21
|
const { Disposable } = require('promise-toolbox')
|
|
22
|
+
const NbdClient = require('@vates/nbd-client')
|
|
22
23
|
|
|
23
|
-
const { warn } = createLogger('xo:backups:DeltaBackupWriter')
|
|
24
|
+
const { debug, warn } = createLogger('xo:backups:DeltaBackupWriter')
|
|
24
25
|
|
|
25
26
|
exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(AbstractDeltaWriter) {
|
|
26
27
|
async checkBaseVdis(baseUuidToSrcVdi) {
|
|
@@ -199,12 +200,30 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
|
|
|
199
200
|
await checkVhd(handler, parentPath)
|
|
200
201
|
}
|
|
201
202
|
|
|
203
|
+
const vdiRef = vm.$xapi.getObject(vdi.uuid).$ref
|
|
204
|
+
|
|
205
|
+
let nbdClient
|
|
206
|
+
if (!this._backup.config.useNbd) {
|
|
207
|
+
// get nbd if possible
|
|
208
|
+
try {
|
|
209
|
+
// this will always take the first host in the list
|
|
210
|
+
const [nbdInfo] = await vm.$xapi.call('VDI.get_nbd_info', vdiRef)
|
|
211
|
+
nbdClient = new NbdClient(nbdInfo)
|
|
212
|
+
await nbdClient.connect()
|
|
213
|
+
debug(`got nbd connection `, { vdi: vdi.uuid })
|
|
214
|
+
} catch (error) {
|
|
215
|
+
nbdClient = undefined
|
|
216
|
+
debug(`can't connect to nbd server or no server available`, { error })
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
202
220
|
await adapter.writeVhd(path, deltaExport.streams[`${id}.vhd`], {
|
|
203
221
|
// no checksum for VHDs, because they will be invalidated by
|
|
204
222
|
// merges and chainings
|
|
205
223
|
checksum: false,
|
|
206
224
|
validator: tmpPath => checkVhd(handler, tmpPath),
|
|
207
225
|
writeBlockConcurrency: this._backup.config.writeBlockConcurrency,
|
|
226
|
+
nbdClient,
|
|
208
227
|
})
|
|
209
228
|
|
|
210
229
|
if (isDelta) {
|