Merge remote-tracking branch 'origin/feature/app-backups' into feature/backups-ui
This commit is contained in:
commit
0248353137
|
@ -1,6 +1,6 @@
|
||||||
import { backups } from "@budibase/pro"
|
import { backups } from "@budibase/pro"
|
||||||
import { objectStore, tenancy, db as dbCore } from "@budibase/backend-core"
|
import { db as dbCore, objectStore, tenancy } from "@budibase/backend-core"
|
||||||
import { AppBackupQueueData } from "@budibase/types"
|
import { AppBackupQueueData, AppBackupStatus } from "@budibase/types"
|
||||||
import { exportApp } from "./exports"
|
import { exportApp } from "./exports"
|
||||||
import { importApp } from "./imports"
|
import { importApp } from "./imports"
|
||||||
import { calculateBackupStats } from "../statistics"
|
import { calculateBackupStats } from "../statistics"
|
||||||
|
@ -42,6 +42,11 @@ async function importProcessor(job: Job) {
|
||||||
await removeExistingApp(devAppId)
|
await removeExistingApp(devAppId)
|
||||||
await performImport(backupTarPath)
|
await performImport(backupTarPath)
|
||||||
}
|
}
|
||||||
|
await backups.updateRestoreStatus(
|
||||||
|
data.docId,
|
||||||
|
data.docRev,
|
||||||
|
AppBackupStatus.COMPLETE
|
||||||
|
)
|
||||||
fs.rmSync(backupTarPath)
|
fs.rmSync(backupTarPath)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -64,13 +69,6 @@ async function exportProcessor(job: Job) {
|
||||||
filename = `${tenantId}/${filename}`
|
filename = `${tenantId}/${filename}`
|
||||||
}
|
}
|
||||||
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
||||||
const metadata = {
|
|
||||||
appId: prodAppId,
|
|
||||||
timestamp,
|
|
||||||
trigger,
|
|
||||||
name,
|
|
||||||
contents,
|
|
||||||
}
|
|
||||||
await objectStore.upload({
|
await objectStore.upload({
|
||||||
path: tarPath,
|
path: tarPath,
|
||||||
type: "application/gzip",
|
type: "application/gzip",
|
||||||
|
@ -83,7 +81,13 @@ async function exportProcessor(job: Job) {
|
||||||
appId: prodAppId,
|
appId: prodAppId,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await backups.storeAppBackupMetadata(filename, metadata)
|
await backups.updateBackupStatus(
|
||||||
|
data.docId,
|
||||||
|
data.docRev,
|
||||||
|
AppBackupStatus.COMPLETE,
|
||||||
|
contents,
|
||||||
|
filename
|
||||||
|
)
|
||||||
// clear up the tarball after uploading it
|
// clear up the tarball after uploading it
|
||||||
fs.rmSync(tarPath)
|
fs.rmSync(tarPath)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,31 +1,41 @@
|
||||||
import { Document } from "../document"
|
import { Document } from "../document"
|
||||||
|
|
||||||
|
export enum AppBackupType {
|
||||||
|
BACKUP = "backup",
|
||||||
|
RESTORE = "restore",
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum AppBackupStatus {
|
||||||
|
STARTED = "started",
|
||||||
|
COMPLETE = "complete",
|
||||||
|
FAILED = "failed",
|
||||||
|
}
|
||||||
|
|
||||||
export enum AppBackupTrigger {
|
export enum AppBackupTrigger {
|
||||||
PUBLISH = "publish",
|
PUBLISH = "publish",
|
||||||
MANUAL = "manual",
|
MANUAL = "manual",
|
||||||
SCHEDULED = "scheduled",
|
SCHEDULED = "scheduled",
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum AppBackupEventType {
|
export interface AppBackupContents {
|
||||||
EXPORT = "export",
|
datasources: string[]
|
||||||
IMPORT = "import",
|
screens: string[]
|
||||||
|
automations: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackupMetadata {
|
export interface AppBackupMetadata {
|
||||||
appId: string
|
appId: string
|
||||||
trigger: AppBackupTrigger
|
trigger?: AppBackupTrigger
|
||||||
|
type: AppBackupType
|
||||||
|
status: AppBackupStatus
|
||||||
name?: string
|
name?: string
|
||||||
createdBy?: string
|
createdBy?: string
|
||||||
timestamp: string
|
timestamp: string
|
||||||
contents: {
|
contents?: AppBackupContents
|
||||||
datasources: string[]
|
|
||||||
screens: string[]
|
|
||||||
automations: string[]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackup extends Document, AppBackupMetadata {
|
export interface AppBackup extends Document, AppBackupMetadata {
|
||||||
filename: string
|
filename?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AppBackupFetchOpts = {
|
export type AppBackupFetchOpts = {
|
||||||
|
@ -38,8 +48,9 @@ export type AppBackupFetchOpts = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AppBackupQueueData {
|
export interface AppBackupQueueData {
|
||||||
eventType: AppBackupEventType
|
|
||||||
appId: string
|
appId: string
|
||||||
|
docId: string
|
||||||
|
docRev: string
|
||||||
export?: {
|
export?: {
|
||||||
trigger: AppBackupTrigger
|
trigger: AppBackupTrigger
|
||||||
name?: string
|
name?: string
|
||||||
|
@ -47,5 +58,6 @@ export interface AppBackupQueueData {
|
||||||
}
|
}
|
||||||
import?: {
|
import?: {
|
||||||
backupId: string
|
backupId: string
|
||||||
|
createdBy?: string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue