Adding a fix for checklist being incorrect after restoring from the CLI.
This commit is contained in:
parent
406cd53d11
commit
2900ef2fde
|
@ -4,7 +4,7 @@ const fs = require("fs")
|
||||||
const { join } = require("path")
|
const { join } = require("path")
|
||||||
const { getAllDbs } = require("../core/db")
|
const { getAllDbs } = require("../core/db")
|
||||||
const tar = require("tar")
|
const tar = require("tar")
|
||||||
const { progressBar } = require("../utils")
|
const { progressBar, httpCall } = require("../utils")
|
||||||
const {
|
const {
|
||||||
TEMP_DIR,
|
TEMP_DIR,
|
||||||
COUCH_DIR,
|
COUCH_DIR,
|
||||||
|
@ -86,6 +86,15 @@ async function importBackup(opts) {
|
||||||
bar.stop()
|
bar.stop()
|
||||||
console.log("MinIO Import")
|
console.log("MinIO Import")
|
||||||
await importObjects()
|
await importObjects()
|
||||||
|
// finish by letting the system know that a restore has occurred
|
||||||
|
try {
|
||||||
|
await httpCall(
|
||||||
|
`http://localhost:${config.MAIN_PORT}/api/system/restored`,
|
||||||
|
"POST"
|
||||||
|
)
|
||||||
|
} catch (err) {
|
||||||
|
// ignore error - it will be an older system
|
||||||
|
}
|
||||||
console.log("Import complete")
|
console.log("Import complete")
|
||||||
fs.rmSync(TEMP_DIR, { recursive: true })
|
fs.rmSync(TEMP_DIR, { recursive: true })
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,14 @@ exports.downloadFile = async (url, filePath) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.httpCall = async (url, method) => {
|
||||||
|
const response = await axios({
|
||||||
|
url,
|
||||||
|
method,
|
||||||
|
})
|
||||||
|
return response.data
|
||||||
|
}
|
||||||
|
|
||||||
exports.getHelpDescription = string => {
|
exports.getHelpDescription = string => {
|
||||||
return chalk.cyan(string)
|
return chalk.cyan(string)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import env from "../../../environment"
|
||||||
|
import { BBContext } from "@budibase/types"
|
||||||
|
import { cache } from "@budibase/backend-core"
|
||||||
|
|
||||||
|
export async function systemRestored(ctx: BBContext) {
|
||||||
|
if (!env.SELF_HOSTED) {
|
||||||
|
ctx.throw(405, "This operation is not allowed in cloud.")
|
||||||
|
}
|
||||||
|
await cache.bustCache(cache.CacheKeys.CHECKLIST)
|
||||||
|
ctx.body = {
|
||||||
|
message: "System prepared after restore.",
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,6 +55,10 @@ const PUBLIC_ENDPOINTS = [
|
||||||
route: "/api/global/users/tenant/:id",
|
route: "/api/global/users/tenant/:id",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
route: "/api/system/restored",
|
||||||
|
method: "POST",
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
const NO_TENANCY_ENDPOINTS = [
|
const NO_TENANCY_ENDPOINTS = [
|
||||||
|
|
|
@ -13,6 +13,7 @@ import selfRoutes from "./global/self"
|
||||||
import licenseRoutes from "./global/license"
|
import licenseRoutes from "./global/license"
|
||||||
import migrationRoutes from "./system/migrations"
|
import migrationRoutes from "./system/migrations"
|
||||||
import accountRoutes from "./system/accounts"
|
import accountRoutes from "./system/accounts"
|
||||||
|
import restoreRoutes from "./system/restore"
|
||||||
|
|
||||||
let userGroupRoutes = api.groups
|
let userGroupRoutes = api.groups
|
||||||
export const routes = [
|
export const routes = [
|
||||||
|
@ -31,4 +32,5 @@ export const routes = [
|
||||||
userGroupRoutes,
|
userGroupRoutes,
|
||||||
migrationRoutes,
|
migrationRoutes,
|
||||||
accountRoutes,
|
accountRoutes,
|
||||||
|
restoreRoutes,
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import * as controller from "../../controllers/system/restore"
|
||||||
|
import Router from "@koa/router"
|
||||||
|
|
||||||
|
const router = new Router()
|
||||||
|
|
||||||
|
router.post("/api/system/restored", controller.systemRestored)
|
||||||
|
|
||||||
|
export = router
|
Loading…
Reference in New Issue