rework backup root

notes:
* backup root cannot come from backend. for dynamic mounts backend cannot know where it is mounted
* backupConfig is 3 parts - format / mount / password . there is also this rootPath (which should not be in db)
* password should be stored separately in settings at some point
* format has to be passed along everywhere because we allow restore from  same backupConfig but different format. we do this by saving the format in the backups table

fixes #819
This commit is contained in:
Girish Ramakrishnan
2023-08-15 20:24:54 +05:30
parent da49a69562
commit aa8c23c8b3
14 changed files with 94 additions and 154 deletions
+4 -11
View File
@@ -15,6 +15,7 @@ const apps = require('./apps.js'),
appstore = require('./appstore.js'),
assert = require('assert'),
AuditSource = require('./auditsource.js'),
backups = require('./backups.js'),
backuptask = require('./backuptask.js'),
BoxError = require('./boxerror.js'),
constants = require('./constants.js'),
@@ -319,17 +320,9 @@ async function install(app, args, progressCallback) {
await services.setupAddons(app, app.manifest.addons);
await services.clearAddons(app, app.manifest.addons);
const backupConfig = restoreConfig.backupConfig;
let mountObject = null;
if (mounts.isManagedProvider(backupConfig.provider)) {
await progressCallback({ percent: 70, message: 'Setting up mount for importing' });
mountObject = { // keep this in sync with importApp in apps.js
name: `appimport-${app.id}`,
hostPath: `/mnt/appimport-${app.id}`,
mountType: backupConfig.provider,
mountOptions: backupConfig.mountOptions
};
await mounts.tryAddMount(mountObject, { timeout: 10 });
}
const mountObject = await backups.setupStorage(backupConfig, `/mnt/appimport-${app.id}`);
if (mountObject) await progressCallback({ percent: 70, message: 'Setting up mount for importing' });
backupConfig.rootPath = backups.getRootPath(backupConfig, `/mnt/appimport-${app.id}`);
await backuptask.downloadApp(app, restoreConfig, (progress) => { progressCallback({ percent: 75, message: progress.message }); });
await apps.restoreConfig(app);
if (mountObject) await mounts.removeMount(mountObject);