1
0
Fork 0
mirror of synced 2024-06-23 08:30:31 +12:00
budibase/packages/server/src/api/controllers/backup.ts

22 lines
793 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
// remove the 120 second limit for the request
ctx.req.setTimeout(0)
const appName = decodeURI(ctx.query.appname)
excludeRows = isQsTrue(excludeRows)
2022-10-12 07:28:13 +13:00
const backupIdentifier = `${appName}-export-${new Date().getTime()}.tar.gz`
2021-01-30 10:52:45 +13:00
ctx.attachment(backupIdentifier)
ctx.body = await sdk.backups.streamExportApp(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
}