forked from tsai/budibase
33 changed files with 1215 additions and 72 deletions
@ -0,0 +1 @@ |
|||||
|
docker-compose --env-file hosting.properties pull && ./start.sh |
||||
File diff suppressed because it is too large
@ -0,0 +1,3 @@ |
|||||
|
export const TableNames = { |
||||
|
USERS: "ta_users", |
||||
|
} |
||||
@ -0,0 +1,41 @@ |
|||||
|
const { performDump } = require("../../utilities/templates") |
||||
|
const path = require("path") |
||||
|
const os = require("os") |
||||
|
const fs = require("fs-extra") |
||||
|
|
||||
|
exports.exportAppDump = async function(ctx) { |
||||
|
const { appId } = ctx.query |
||||
|
|
||||
|
const backupsDir = path.join(os.homedir(), ".budibase", "backups") |
||||
|
fs.ensureDirSync(backupsDir) |
||||
|
|
||||
|
const backupIdentifier = `${appId} Backup: ${new Date()}.txt` |
||||
|
|
||||
|
await performDump({ |
||||
|
dir: backupsDir, |
||||
|
appId, |
||||
|
name: backupIdentifier, |
||||
|
}) |
||||
|
|
||||
|
ctx.status = 200 |
||||
|
|
||||
|
const backupFile = path.join(backupsDir, backupIdentifier) |
||||
|
|
||||
|
ctx.attachment(backupIdentifier) |
||||
|
ctx.body = fs.createReadStream(backupFile) |
||||
|
// ctx.body = {
|
||||
|
// url: `/api/backups/download/${backupIdentifier}`,
|
||||
|
// }
|
||||
|
} |
||||
|
|
||||
|
// exports.downloadAppDump = async function(ctx) {
|
||||
|
// const fileName = ctx.params.fileName
|
||||
|
|
||||
|
// const backupsDir = path.join(os.homedir(), ".budibase", "backups")
|
||||
|
// fs.ensureDirSync(backupsDir)
|
||||
|
|
||||
|
// const backupFile = path.join(backupsDir, fileName)
|
||||
|
|
||||
|
// ctx.attachment(fileName)
|
||||
|
// ctx.body = fs.createReadStream(backupFile)
|
||||
|
// }
|
||||
@ -0,0 +1,15 @@ |
|||||
|
const Router = require("@koa/router") |
||||
|
const controller = require("../controllers/backup") |
||||
|
const authorized = require("../../middleware/authorized") |
||||
|
const { BUILDER } = require("../../utilities/security/permissions") |
||||
|
|
||||
|
const router = Router() |
||||
|
|
||||
|
router.get("/api/backups/export", authorized(BUILDER), controller.exportAppDump) |
||||
|
// .get(
|
||||
|
// "/api/backups/download/:fileName",
|
||||
|
// authorized(BUILDER),
|
||||
|
// controller.downloadAppDump
|
||||
|
// )
|
||||
|
|
||||
|
module.exports = router |
||||
Loading…
Reference in new issue