Skip to content

[Bug]: appsmithctl restore ignores --backup-db-name=<name> and restores from the manifest database name #42295

Description

@breken-ai

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 @ a6ab36c) checks command_args.includes("--backup-db-name"). That only matches an argument that is exactly --backup-db-name. So:

  • --backup-db-name=legacy-db never enters the override branch. The name comes from the manifest ("Backup Database Name: <manifest name>"), and restoreDatabase passes that manifest name to mongorestore --nsFrom.
  • --backup-db-name legacy-db (space form) enters the branch, but command_args[i].split("=")[1] is undefined. The db name becomes undefined.

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

  1. Take a backup whose manifest.json has "dbName": "manifest-db", where the data was actually dumped from legacy-db.
  2. Run appsmithctl restore --backup-db-name=legacy-db.
  3. The log prints Backup Database Name: manifest-db, and mongorestore runs 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 @ a6ab36c

Prepared with AI assistance (Claude) from the breken-ai account.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions