app: add export route

Currently, the export route only creates the snapshot (the other side
of in-place import). In the future, the export route can export to a
custom backup config (like import).
This commit is contained in:
Girish Ramakrishnan
2020-12-06 19:38:50 -08:00
parent c6fd922fcd
commit 78752fde7a
5 changed files with 37 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ exports = module.exports = {
restore,
importApp,
exportApp,
clone,
update,
@@ -1549,6 +1550,26 @@ function importApp(app, data, auditSource, callback) {
});
}
function exportApp(app, data, auditSource, callback) {
assert.strictEqual(typeof app, 'object');
assert.strictEqual(typeof callback, 'function');
const appId = app.id;
let error = checkAppState(app, exports.ISTATE_PENDING_BACKUP);
if (error) return callback(error);
const task = {
args: { snapshotOnly: true },
values: {}
};
addTask(appId, exports.ISTATE_PENDING_BACKUP, task, (error, result) => {
if (error) return callback(error);
callback(null, { taskId: result.taskId });
});
}
function purchaseApp(data, callback) {
assert.strictEqual(typeof data, 'object');
assert.strictEqual(typeof callback, 'function');