Merge branch 'feature/app-backups' of github.com:Budibase/budibase into feature/backups-ui

This commit is contained in:
mike12345567 2022-10-21 18:26:52 +01:00
commit e828323576
6 changed files with 594 additions and 35 deletions

View File

@ -26,7 +26,7 @@
"aws-sdk": "2.1030.0",
"bcrypt": "5.0.1",
"bcryptjs": "2.4.3",
"bull": "^4.10.1",
"bull": "4.10.1",
"dotenv": "16.0.1",
"emitter-listener": "1.1.2",
"ioredis": "4.28.0",
@ -63,9 +63,8 @@
]
},
"devDependencies": {
"@types/bull": "^3.15.9",
"@types/chance": "1.1.3",
"@types/ioredis": "^4.28.10",
"@types/ioredis": "4.28.10",
"@types/jest": "27.5.1",
"@types/koa": "2.0.52",
"@types/lodash": "4.14.180",

View File

@ -93,7 +93,7 @@
"arangojs": "7.2.0",
"aws-sdk": "2.1030.0",
"bcryptjs": "2.4.3",
"bull": "4.8.5",
"bull": "4.10.1",
"chmodr": "1.2.0",
"chokidar": "3.5.3",
"csvtojson": "2.0.10",
@ -159,9 +159,9 @@
"@jest/test-sequencer": "24.9.0",
"@types/apidoc": "0.50.0",
"@types/bson": "4.2.0",
"@types/bull": "3.15.8",
"@types/global-agent": "2.1.1",
"@types/google-spreadsheet": "3.1.5",
"@types/ioredis": "4.28.10",
"@types/jest": "27.5.1",
"@types/koa": "2.13.5",
"@types/koa__router": "8.0.11",

View File

@ -89,6 +89,11 @@ async function importProcessor(job: Job) {
const tenantId = tenancy.getTenantIDFromAppID(appId) as string
tenancy.doInTenant(tenantId, async () => {
const devAppId = dbCore.getDevAppID(appId)
const { rev } = await backups.updateRestoreStatus(
data.docId,
data.docRev,
AppBackupStatus.PENDING
)
// initially export the current state to disk - incase something goes wrong
await runBackup(
nameForBackup,
@ -113,7 +118,7 @@ async function importProcessor(job: Job) {
} catch (err) {
status = AppBackupStatus.FAILED
}
await backups.updateRestoreStatus(data.docId, data.docRev, status)
await backups.updateRestoreStatus(data.docId, rev, status)
})
}
@ -124,8 +129,13 @@ async function exportProcessor(job: Job) {
name = data.export!.name || `${trigger} - backup`
const tenantId = tenancy.getTenantIDFromAppID(appId) as string
await tenancy.doInTenant(tenantId, async () => {
const { rev } = await backups.updateBackupStatus(
data.docId,
data.docRev,
AppBackupStatus.PENDING
)
return runBackup(name, trigger, tenantId, appId, {
doc: { id: data.docId, rev: data.docRev },
doc: { id: data.docId, rev },
})
})
}

File diff suppressed because it is too large Load Diff

View File

@ -8,6 +8,7 @@ export enum AppBackupType {
export enum AppBackupStatus {
STARTED = "started",
PENDING = "pending",
COMPLETE = "complete",
FAILED = "failed",
}

View File

@ -9,6 +9,7 @@ export interface ContextUser extends User {
export interface BBContext {
user?: ContextUser
status?: number
request: {
body: any
}