Problem restoring database

tried: bench restore /home/frappe/backups/20241013_092921-my_site_local-database.sql.gz
and got the following:

b'/usr/bin/bash: line 1: file: command not found\n'
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 142, in restore
    _restore(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 174, in _restore
    err, out = frappe.utils.execute_in_shell(f"file {sql_file_path}", check_exit_code=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/__init__.py", line 484, in execute_in_shell
    raise frappe.CommandFailedError(
frappe.exceptions.CommandFailedError: Command failed

The site is named the same as before.
Luckily, it’s a test environment, but still…

Extract the sql file first then restore:

gzip -d /home/frappe/backups/20241013_092921-my_site_local-database.sql.gz

bench --force restore /home/frappe/backups/20241013_092921-my_site_local-database.sql

1 Like

Navigate to your Frappe installation directory and use the following command to restore the SQL backup:

bench --site [sitename] --force restore /path/to/your/backup.sql

  • Replace [sitename] with the name of your Frappe site.
  • Replace /path/to/your/backup.sql with the path to your SQL backup file.
  • Use --force if you’re restoring to a new site or replacing an existing database.

Tried it. Got the same error, so I decided to change the approach and did:

 mariadb -uroot -p _e38f80c9b543005c < ../BU/20241014_000002-my_site_local-database.sql

and it did work…
:thinking:

Does anyone have an idea what’s going on?
What is the command that is not found
:unamused:

Maybe @flexy2ky . I installed the new server according to your guide.
Do you have any thoughts regarding this issue?

@abrefael Unfortunately i have no idea what the issue is as i have not encountered this before and the error log doesn’t help me much.

@abrefael For restoring the database of another site follow these steps.

Step 1. Make sure you have installed apps that are present on another site.

Step 2. Go to the frappe bench directory (ex: /home/workspace/development/frappe-bench) if the bench name is frappe-bench

Step 3. Use this command to restore the database bench --site site_name restore --force database_file_path

Step 4. After restoring database successfully migrate the site bench --site site_name migrate

@Vipul_Kumar I had done this exactly.
I also tried to forego an app, and exclude it from the backup in the first place. But no luck.

I tried reinstalling the server, but the same error comes up.
I will try again today…

still getting the same error:

b'/usr/bin/bash: line 1: file: command not found\n'
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 168, in restore
    _restore(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 200, in _restore
    err, out = frappe.utils.execute_in_shell(f"file {sql_file_path}", check_exit_code=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/__init__.py", line 484, in execute_in_shell
    raise frappe.CommandFailedError(
frappe.exceptions.CommandFailedError: Command failed

:pensive:

So I have had enough of this…
As I only have 8 active tables in my app (and a few child tables…), I just imported everything using CSV files…
Crude, but works… :slight_smile: