backups: set label of backup and control it's retention

This commit is contained in:
Girish Ramakrishnan
2022-04-02 17:09:08 -07:00
parent d47b39d90b
commit 70695b1b0f
12 changed files with 174 additions and 19 deletions

View File

@@ -50,6 +50,8 @@ exports = module.exports = {
uploadFile,
downloadFile,
updateBackup,
getLimits,
load
@@ -798,6 +800,21 @@ async function listBackups(req, res, next) {
next(new HttpSuccess(200, { backups: result }));
}
async function updateBackup(req, res, next) {
assert.strictEqual(typeof req.app, 'object');
assert.strictEqual(typeof req.params.backupId, 'string');
assert.strictEqual(typeof req.body, 'object');
const { label, preserveSecs } = req.body;
if (typeof label !== 'string') return next(new HttpError(400, 'label must be a string'));
if (typeof preserveSecs !== 'number') return next(new HttpError(400, 'preserveSecs must be a number'));
const [error] = await safe(apps.updateBackup(req.app, req.params.backupId, { label, preserveSecs }));
if (error) return next(BoxError.toHttpError(error));
next(new HttpSuccess(200, {}));
}
async function uploadFile(req, res, next) {
assert.strictEqual(typeof req.app, 'object');