1
0
Fork 0
mirror of synced 2024-06-28 11:00:55 +12:00
budibase/packages/server/src/api/controllers/backup.js

19 lines
704 B
JavaScript
Raw Normal View History

const { streamBackup } = require("../../utilities/fileSystem")
const { events, context } = require("@budibase/backend-core")
const { DocumentType } = require("../../db/utils")
2021-01-28 02:55:46 +13:00
2021-05-03 19:31:09 +12:00
exports.exportAppDump = async function (ctx) {
2022-06-07 02:17:14 +12:00
let { appId, excludeRows } = ctx.query
const appName = decodeURI(ctx.query.appname)
2022-06-07 02:17:14 +12:00
excludeRows = excludeRows === "true"
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
2021-01-30 10:52:45 +13:00
ctx.attachment(backupIdentifier)
2022-06-07 02:17:14 +12:00
ctx.body = await streamBackup(appId, excludeRows)
await context.doInAppContext(appId, async () => {
const appDb = context.getAppDB()
const app = await appDb.get(DocumentType.APP_METADATA)
await events.app.exported(app)
})
2021-01-28 02:55:46 +13:00
}