mirror of https://github.com/Budibase/budibase.git
10 changed files with 134 additions and 16 deletions
@ -0,0 +1,10 @@ |
|||||
|
FROM ubuntu:latest |
||||
|
|
||||
|
|
||||
|
FROM envoyproxy/envoy:v1.16-latest |
||||
|
COPY envoy.yaml /etc/envoy/envoy.yaml |
||||
|
|
||||
|
FROM apache/couchdb:3.0 as db |
||||
|
|
||||
|
FROM minio/minio |
||||
|
|
||||
@ -0,0 +1,36 @@ |
|||||
|
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.request.body |
||||
|
|
||||
|
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 |
||||
|
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,16 @@ |
|||||
|
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 |
||||
|
.post("/api/backups/export", authorized(BUILDER), controller.exportAppDump) |
||||
|
.get( |
||||
|
"/api/backups/download/:fileName", |
||||
|
authorized(BUILDER), |
||||
|
controller.downloadAppDump |
||||
|
) |
||||
|
|
||||
|
module.exports = router |
||||
Loading…
Reference in new issue