Minor fixes after testing manual backup system.
This commit is contained in:
parent
a20ad3233e
commit
758c46ce83
|
@ -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,12 +10,13 @@ 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 tenantId = tenancy.getTenantIDFromAppID(appId)
|
||||||
|
await tenancy.doInTenant(tenantId, async () => {
|
||||||
const createdAt = new Date().toISOString()
|
const createdAt = new Date().toISOString()
|
||||||
const tarPath = await exportApp(appId, { tar: true })
|
const tarPath = await exportApp(appId, { tar: true })
|
||||||
let filename = `${appId}/backup-${createdAt}.tar.gz`
|
let filename = `${appId}/backup-${createdAt}.tar.gz`
|
||||||
// add the tenant to the bucket path if backing up within a multi-tenant environment
|
// add the tenant to the bucket path if backing up within a multi-tenant environment
|
||||||
if (env.MULTI_TENANCY) {
|
if (env.MULTI_TENANCY) {
|
||||||
const tenantId = tenancy.getTenantIDFromAppID(appId)
|
|
||||||
filename = `${tenantId}/${filename}`
|
filename = `${tenantId}/${filename}`
|
||||||
}
|
}
|
||||||
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
const bucket = objectStore.ObjectStoreBuckets.BACKUPS
|
||||||
|
@ -36,4 +37,5 @@ export async function init() {
|
||||||
// clear up the tarball after uploading it
|
// clear up the tarball after uploading it
|
||||||
fs.rmSync(tarPath)
|
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
|
||||||
|
request: {
|
||||||
body: any
|
body: any
|
||||||
|
}
|
||||||
|
params: any
|
||||||
|
body?: any
|
||||||
|
redirect?: any
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue