[Bug]: appsmithctl restore ignores --backup-db-name=<name> and restores from the manifest database name
Is there an existing issue for this?
- I have searched the existing issues
Description
appsmithctl restore --backup-db-name=<name> ignores the override and restores using the database name from the backup's manifest.json.
getBackupDatabaseName in app/client/packages/rts/src/ctl/restore.ts:415-440 (release @ a6ab36cb26) checks command_args.includes("--backup-db-name"). That only matches an argument that is exactly --backup-db-name. So:
--backup-db-name=legacy-dbnever enters the override branch. The name comes from the manifest ("Backup Database Name: <manifest name>"), andrestoreDatabasepasses that manifest name tomongorestore --nsFrom.--backup-db-name legacy-db(space form) enters the branch, butcommand_args[i].split("=")[1]isundefined. The db name becomesundefined.
As a result, the one flag that exists for restoring a backup taken from a differently named database (#25663, #31004) cannot actually be used. --nsFrom maps from the wrong namespace, and the restore can silently omit the data.
What I expect is that --backup-db-name=<name> overrides the manifest name.
Steps To Reproduce
- Take a backup whose
manifest.jsonhas"dbName": "manifest-db", where the data was actually dumped fromlegacy-db. - Run
appsmithctl restore --backup-db-name=legacy-db. - The log prints
Backup Database Name: manifest-db, andmongorestoreruns with--nsFrom=manifest-db.*.
Failing unit test (red on release, green with the fix):
it("uses --backup-db-name= when remapping a backup to the target database", async () => {
jest.spyOn(fsPromises, "readFile").mockResolvedValue(JSON.stringify({ dbName: "manifest-db" }));
await expect(getBackupDatabaseName("/contents", ["--backup-db-name=legacy-db"])).resolves.toBe("legacy-db");
});
// release: received "manifest-db"Proposed approach (a fix with a regression test is ready): use the existing getArgValue helper in restore.ts (already used for --backup-file=) to read --backup-db-name=<name>, and keep the manifest fallback. With that change the space form falls back to the manifest name, not undefined. The change is confined to restore.ts. getBackupDatabaseName gains an args parameter that defaults to command_args, so it can be tested. It adds 2 tests in restore.test.ts. The restore suite passes (17/17), along with RTS tsc, ESLint and Prettier.
@contributor-support I'd like to take this. Could it be assigned to me? I'll open the PR against release with Fixes #<this> once it's assigned.
Public Sample App
No response
Environment
Release
Severity
Medium (Frustrating UX)
Issue video log
No response
Version
Self Hosted - release @ a6ab36cb26
Prepared with AI assistance (Claude) from the breken-ai account.
Source: appsmithorg/appsmith