add backupCommand, restoreCommand, persistentDirs
This commit is contained in:
@@ -332,6 +332,7 @@ async function uninstallCommand(app, args, progressCallback) {
|
||||
|
||||
await progressCallback({ percent: 30, message: 'Teardown addons' });
|
||||
await services.teardownAddons(app, app.manifest.addons);
|
||||
await services.teardownPersistentDirs(app);
|
||||
|
||||
await progressCallback({ percent: 40, message: 'Cleanup file manager' });
|
||||
|
||||
@@ -445,15 +446,19 @@ async function installCommand(app, args, progressCallback) {
|
||||
if (!restoreConfig) { // install
|
||||
await progressCallback({ percent: 60, message: 'Setting up addons' });
|
||||
await services.setupAddons(app, app.manifest.addons);
|
||||
await services.setupPersistentDirs(app);
|
||||
} else if (app.installationState === apps.ISTATE_PENDING_IMPORT && restoreConfig.inPlace) { // in-place import
|
||||
await progressCallback({ percent: 60, message: 'Importing addons in-place' });
|
||||
await services.setupAddons(app, app.manifest.addons);
|
||||
await services.setupPersistentDirs(app);
|
||||
await services.clearAddons(app, _.omit(app.manifest.addons, ['localstorage']));
|
||||
await apps.loadConfig(app);
|
||||
await services.restoreAddons(app, app.manifest.addons);
|
||||
await services.runRestoreCommand(app);
|
||||
} else if ((app.installationState === apps.ISTATE_PENDING_IMPORT || app.installationState === apps.ISTATE_PENDING_RESTORE) && restoreConfig.remotePath) { // app import or app restore during full box restore
|
||||
await progressCallback({ percent: 65, message: 'Downloading backup and restoring addons' });
|
||||
await services.setupAddons(app, app.manifest.addons);
|
||||
await services.setupPersistentDirs(app);
|
||||
await services.clearAddons(app, app.manifest.addons);
|
||||
const backupSite = restoreConfig.backupSite;
|
||||
await backupSites.storageApi(backupSite).setup(backupSite.config);
|
||||
@@ -462,9 +467,11 @@ async function installCommand(app, args, progressCallback) {
|
||||
await backupSites.storageApi(backupSite).teardown(backupSite.config);
|
||||
await progressCallback({ percent: 75, message: 'Restoring addons' });
|
||||
await services.restoreAddons(app, app.manifest.addons);
|
||||
await services.runRestoreCommand(app);
|
||||
} else { // clone and restore
|
||||
await progressCallback({ percent: 65, message: 'Downloading backup and restoring addons' });
|
||||
await services.setupAddons(app, app.manifest.addons);
|
||||
await services.setupPersistentDirs(app);
|
||||
await services.clearAddons(app, app.manifest.addons);
|
||||
await backuptask.downloadApp(app, restoreConfig, (progress) => { progressCallback({ percent: 65, message: progress.message }); });
|
||||
if (app.installationState === apps.ISTATE_PENDING_CLONE) {
|
||||
@@ -473,6 +480,7 @@ async function installCommand(app, args, progressCallback) {
|
||||
}
|
||||
await progressCallback({ percent: 70, message: 'Restoring addons' });
|
||||
await services.restoreAddons(app, app.manifest.addons);
|
||||
await services.runRestoreCommand(app);
|
||||
}
|
||||
|
||||
// now we have the local package tarball, so lets build
|
||||
@@ -725,6 +733,13 @@ async function updateCommand(app, args, progressCallback) {
|
||||
await services.teardownAddons(app, unusedAddons);
|
||||
if (Object.keys(unusedAddons).includes('localstorage')) await updateApp(app, { storageVolumeId: null, storageVolumePrefix: null }); // lose reference
|
||||
|
||||
// teardown persistent dirs removed in the new manifest
|
||||
const newPersistentDirs = updateConfig.manifest.persistentDirs || [];
|
||||
const removedPersistentDirs = (app.manifest.persistentDirs || []).filter(d => !newPersistentDirs.includes(d));
|
||||
if (removedPersistentDirs.length) {
|
||||
await services.teardownPersistentDirs({ ...app, manifest: { persistentDirs: removedPersistentDirs } });
|
||||
}
|
||||
|
||||
// free unused ports. this is done after backup, so the app object is not in some inconsistent state should backup fail
|
||||
const newTcpPorts = updateConfig.manifest.tcpPorts || {};
|
||||
const newUdpPorts = updateConfig.manifest.udpPorts || {};
|
||||
@@ -767,6 +782,7 @@ async function updateCommand(app, args, progressCallback) {
|
||||
|
||||
await progressCallback({ percent: 60, message: 'Updating addons' });
|
||||
await services.setupAddons(app, updateConfig.manifest.addons);
|
||||
await services.setupPersistentDirs(app);
|
||||
|
||||
// now we have the local package tarball, so lets build
|
||||
if (app.manifest.dockerImage.indexOf('local/') === 0) {
|
||||
|
||||
Reference in New Issue
Block a user