Minor fixes after testing manual backup system.
This commit is contained in:
parent
0bd2a18e46
commit
1373630b33
|
@ -53,6 +53,9 @@ export const getTenantIDFromAppID = (appId: string) => {
|
||||||
if (!appId) {
|
if (!appId) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
if (!isMultiTenant()) {
|
||||||
|
return DEFAULT_TENANT_ID
|
||||||
|
}
|
||||||
const split = appId.split(SEPARATOR)
|
const split = appId.split(SEPARATOR)
|
||||||
const hasDev = split[1] === DocumentType.DEV
|
const hasDev = split[1] === DocumentType.DEV
|
||||||
if ((hasDev && split.length === 3) || (!hasDev && split.length === 2)) {
|
if ((hasDev && split.length === 3) || (!hasDev && split.length === 2)) {
|
||||||
|
|
|
@ -34,6 +34,8 @@ export { default as publicRoutes } from "./public"
|
||||||
const appBackupRoutes = api.appBackups
|
const appBackupRoutes = api.appBackups
|
||||||
const scheduleRoutes = api.schedules
|
const scheduleRoutes = api.schedules
|
||||||
export const mainRoutes: Router[] = [
|
export const mainRoutes: Router[] = [
|
||||||
|
appBackupRoutes,
|
||||||
|
backupRoutes,
|
||||||
authRoutes,
|
authRoutes,
|
||||||
deployRoutes,
|
deployRoutes,
|
||||||
layoutRoutes,
|
layoutRoutes,
|
||||||
|
@ -53,16 +55,14 @@ export const mainRoutes: Router[] = [
|
||||||
permissionRoutes,
|
permissionRoutes,
|
||||||
datasourceRoutes,
|
datasourceRoutes,
|
||||||
queryRoutes,
|
queryRoutes,
|
||||||
backupRoutes,
|
|
||||||
metadataRoutes,
|
metadataRoutes,
|
||||||
devRoutes,
|
devRoutes,
|
||||||
cloudRoutes,
|
cloudRoutes,
|
||||||
// these need to be handled last as they still use /api/:tableId
|
|
||||||
// this could be breaking as koa may recognise other routes as this
|
|
||||||
tableRoutes,
|
|
||||||
rowRoutes,
|
rowRoutes,
|
||||||
migrationRoutes,
|
migrationRoutes,
|
||||||
pluginRoutes,
|
pluginRoutes,
|
||||||
appBackupRoutes,
|
|
||||||
scheduleRoutes,
|
scheduleRoutes,
|
||||||
|
// these need to be handled last as they still use /api/:tableId
|
||||||
|
// this could be breaking as koa may recognise other routes as this
|
||||||
|
tableRoutes,
|
||||||
]
|
]
|
||||||
|
|
|
@ -10,30 +10,32 @@ export async function init() {
|
||||||
const appId = job.data.appId,
|
const appId = job.data.appId,
|
||||||
trigger = job.data.trigger,
|
trigger = job.data.trigger,
|
||||||
name = job.data.name
|
name = job.data.name
|
||||||
const createdAt = new Date().toISOString()
|
const tenantId = tenancy.getTenantIDFromAppID(appId)
|
||||||
const tarPath = await exportApp(appId, { tar: true })
|
await tenancy.doInTenant(tenantId, async () => {
|
||||||
let filename = `${appId}/backup-${createdAt}.tar.gz`
|
const createdAt = new Date().toISOString()
|
||||||
// add the tenant to the bucket path if backing up within a multi-tenant environment
|
const tarPath = await exportApp(appId, { tar: true })
|
||||||
if (env.MULTI_TENANCY) {
|
let filename = `${appId}/backup-${createdAt}.tar.gz`
|
||||||
const tenantId = tenancy.getTenantIDFromAppID(appId)
|
// add the tenant to the bucket path if backing up within a multi-tenant environment
|
||||||
filename = `${tenantId}/${filename}`
|
if (env.MULTI_TENANCY) {
|
||||||
}
|
filename = `${tenantId}/${filename}`
|
||||||
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
}
|
||||||
const metadata = {
|
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
||||||
appId,
|
const metadata = {
|
||||||
createdAt,
|
appId,
|
||||||
trigger,
|
createdAt,
|
||||||
name,
|
trigger,
|
||||||
}
|
name,
|
||||||
await objectStore.upload({
|
}
|
||||||
path: tarPath,
|
await objectStore.upload({
|
||||||
type: "application/gzip",
|
path: tarPath,
|
||||||
bucket,
|
type: "application/gzip",
|
||||||
filename,
|
bucket,
|
||||||
metadata,
|
filename,
|
||||||
|
metadata,
|
||||||
|
})
|
||||||
|
await backups.storeAppBackupMetadata(filename, metadata)
|
||||||
|
// clear up the tarball after uploading it
|
||||||
|
fs.rmSync(tarPath)
|
||||||
})
|
})
|
||||||
await backups.storeAppBackupMetadata(filename, metadata)
|
|
||||||
// clear up the tarball after uploading it
|
|
||||||
fs.rmSync(tarPath)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,12 @@ export interface ContextUser extends User {
|
||||||
license: License
|
license: License
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BBContext extends Context {
|
export interface BBContext {
|
||||||
user?: ContextUser
|
user?: ContextUser
|
||||||
body: any
|
request: {
|
||||||
|
body: any
|
||||||
|
}
|
||||||
|
params: any
|
||||||
|
body?: any
|
||||||
|
redirect?: any
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue