1
0
Fork 0
mirror of synced 2024-09-30 00:57:16 +13:00
budibase/packages/server/src/api/controllers/backup.ts

20 lines
719 B
TypeScript
Raw Normal View History

import sdk from "../../sdk"
import { events, context } from "@budibase/backend-core"
import { DocumentType } from "../../db/utils"
import { isQsTrue } from "../../utilities"
2021-01-28 02:55:46 +13:00
export async function exportAppDump(ctx: any) {
2022-06-07 02:17:14 +12:00
let { appId, excludeRows } = ctx.query
const appName = decodeURI(ctx.query.appname)
excludeRows = isQsTrue(excludeRows)
const backupIdentifier = `${appName}-export-${new Date().getTime()}.txt`
2021-01-30 10:52:45 +13:00
ctx.attachment(backupIdentifier)
ctx.body = await sdk.apps.exports.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
}