bench restore not working in shell
Closed this issue · 1 comments
This issue tracker is only for issues related to Frappe-Manager. Please use https://github.com/rtcamp/frappe-manager/discussions for support questions.
Describe the bug
The "bench restore" command throws an error when trying to restore a backup.
To Reproduce
Steps to reproduce the behavior:
- Run command 'bench restore database-backup-file-created-with-bench-backup.sql.gz' from site shell.
- See error:
b'/usr/bin/bash: line 1: file: command not found\n'
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/workspace/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in
main()
File "/workspace/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
click.Group(commands=commands)(prog_name="bench")
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/env/lib/python3.11/site-packages/click/decorators.py", line 33, in new_func
return f(get_current_context(), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/apps/frappe/frappe/commands/init.py", line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/apps/frappe/frappe/commands/site.py", line 135, in restore
_restore(
File "/workspace/frappe-bench/apps/frappe/frappe/commands/site.py", line 167, in _restore
err, out = frappe.utils.execute_in_shell(f"file {sql_file_path}", check_exit_code=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/frappe-bench/apps/frappe/frappe/utils/init.py", line 484, in execute_in_shell
raise frappe.CommandFailedError(
frappe.exceptions.CommandFailedError: Command failed
Expected behavior
Backup successfully restored.
System information (please complete the following information):
-
fm --version
0.14.0 -
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble -
docker version
Client: Docker Engine - Community
Version: 26.1.4
API version: 1.45
Go version: go1.21.11
Git commit: 5650f9b
Built: Wed Jun 5 11:28:57 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.1.4
API version: 1.45 (minimum version 1.24)
Go version: go1.21.11
Git commit: de5c9cf
Built: Wed Jun 5 11:28:57 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.33
GitCommit: d2d58213f83a351ca8f528a95fbd145f5654e957
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0 -
docker-compose version
ordocker compose version
Docker Compose version v2.27.1
Attach log
Please attach logs from ~/frappe/logs/fm.log
for faster resolution.
N/A
Additional context
Add any other context about the problem here.
This error occurs because file
command is not found in the frappe docker image. Expect the fix in the upcoming release/patch.
In the meantime to fix this issue you can use sudo apt update && sudo apt install -y file
to install the file command and then use bench restore
.