Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using bench restore after bench migrate on Frappe v14 #22430

Open
jcastillopro opened this issue Sep 15, 2023 · 2 comments
Open

Error using bench restore after bench migrate on Frappe v14 #22430

jcastillopro opened this issue Sep 15, 2023 · 2 comments
Labels

Comments

@jcastillopro
Copy link

jcastillopro commented Sep 15, 2023

Description of the issue

When attempting to restore a backup using the bench restore command, a syntax error occurs. This seems to be related to specific lines within the INSERT INTO tabInstalled Application section of the SQL backup. Removing the following lines from the backup resolves the error and allows for a successful restore:
INSERT INTO `tabInstalled Application` VALUES ('395eb762aa','2023-09-15 09:58:54.927698','2023-09-15 09:58:54.927698','Administrator','Administrator',0,1,'frappe','14.49.0','version-14','Installed Applications','installed_applications','Installed Applications'), ('fe1a7e895f','2023-09-15 09:58:54.929526','2023-09-15 09:58:54.929526','Administrator','Administrator',0,2,'erpnext','14.39.0','version-14','Installed Applications','installed_applications','Installed Applications');

On the left, the SQL before performing the migration, and on the right, after the migration

image

Context information (for bug reports)

Output of bench version

Frappe Framework: v14.49.0 (version-14)

Steps to reproduce the issue

  • bench migrate.
  • Create a backup of the current site using bench backup.
  • Attempt to restore the backup using bench restore command, pointing to the previously created backup file.
  • Observed result
    A syntax error is encountered, preventing the restore from completing.
Stacktrace / full error message
Traceback (most recent call last):
frappe@70dc0f77bc92:/workspace/development/frappe-bench/sites/development.localhost/private/backups$ bench restore /workspace/development/frappe-bench/sites/development.localhost/private/backups/20230915_095913-development_localhost-database.sql
Traceback (most recent call last):
  File "/home/frappe/.pyenv/versions/3.10.12/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/frappe/.pyenv/versions/3.10.12/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 109, in <module>
    main()
  File "/workspace/development/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/workspace/development/frappe-bench/env/lib/python3.10/site-packages/click/decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 29, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/commands/site.py", line 202, in restore
    if not force and is_downgrade(decompressed_file_name, verbose=True):
  File "/workspace/development/frappe-bench/apps/frappe/frappe/installer.py", line 789, in is_downgrade
    app_rows = frappe.safe_eval(line)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/__init__.py", line 2279, in safe_eval
    return safe_eval(code, eval_globals, eval_locals)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/utils/safe_exec.py", line 99, in safe_eval
    _validate_safe_eval_syntax(code)
  File "/workspace/development/frappe-bench/apps/frappe/frappe/utils/safe_exec.py", line 117, in _validate_safe_eval_syntax
    tree = ast.parse(code, mode="eval")
  File "/home/frappe/.pyenv/versions/3.10.12/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 0
    SyntaxError: invalid syntax 
  • Expected result
    The backup should restore successfully without any errors.

Additional information

OS version / distribution: Ubuntu 22.04.2 LTS, Windows 11]
Frappe install method: Docker environment

Additional context:

  • The issue was observed in both versions v14.43.0 and v14.49.0 of Frappe Framework.
  • The restore works fine with the backup taken before the bench migrate or when forced. The site is set as default
  • The tests were conducted in a clean environment
@ophl55
Copy link

ophl55 commented Oct 10, 2023

I receive the same error message on frappe v14.51.0.

@mepoland
Copy link

I had the same problem, at least the traceback looks identical from a brief scan. But the path I took to get to this error was different, and the backup was created before I ever ran migrate:

  • I installed a dockerized erpnext v14.44.1 on ~10/19/2023 following the single server example instructions. I'm running a DigitalOcean droplet.
  • Turned on Google Drive backup service. Last backup was last night at midnight.
  • Attempted to upgrade to erpnext v15 today. Failed because the migrate command got hung up on 'Updating doctypes for frappe’ at 2%. Gave up and decided to try a fresh re-install of v14.44.1 using DB backups since my database might now be partially corrupted.
  • Removed all containers, images and volumes from the server; pulled a fresh frappe_docker repo and attempted to re-install v14.44.1.
  • Copied backup files into container and ran bench restore. Got the syntax error.
  • Pulled hair out for a while and eventually tried adding --force. This appears to have restored everything correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants