How to test new release before upgrading it on production server

  • Download the latest backup of production server locally. For latest backup run command bench backup --with-files on production server
  • Extract the .sql file with comand gunzip prod_backup.sql.gz
  • Setup latest bench locally e.g. bench for v8 on laptop
  • Create new site on this fresh installed bench
bench new-site test_new
  • check for the database name of test_new site
cat ~/frappe-bench/sites/test_new/site_config.json
 "db_name": "e4ewfe0606", 
 "db_password": "qRKQKWJfseCMI"

  • enter into mysql prompt as root
mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8248
Server version: 10.1.21-MariaDB-1~yakkety binary distribution

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

  • replace the identified database with blank database.
MariaDB [(none)]> drop database `e4ewfe0606`; create database `e4ewfe0606`;
  • Restore production database into local blank database
mysql -u  root -p e4ewfe0606 <  prod_backup.sql
  • Update bench
bench update --upgrade

This will run the new update patches on production database installed locally.


Why use “bench update --upgrade” in last after restore whereas we are using already new version8 on local server?

I created new site in v8 then imported database to local. When i hitting bench update it throwing error,
ImportError: Module import failed for Payment Tool (erpnext.accounts.doctype.payment_tool.payment_tool)

Traceback is
Traceback (most recent call last): File "/usr/lib/python2.7/", line 162, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib/python2.7/", line 72, in _run_code exec code in run_globals File "/opt/erp7/frappe-bench/apps/frappe/frappe/utils/", line 79, in <module> main() File "/opt/erp7/frappe-bench/apps/frappe/frappe/utils/", line 16, in main click.Group(commands=commands)(prog_name='bench') File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 722, in __call__ return self.main(*args, **kwargs) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 697, in main rv = self.invoke(ctx) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 1066, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 895, in invoke return ctx.invoke(self.callback, **ctx.params) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 535, in invoke return callback(*args, **kwargs) File "/opt/erp7/frappe-bench/env/local/lib/python2.7/site-packages/click/", line 17, in new_func return f(get_current_context(), *args, **kwargs) File "/opt/erp7/frappe-bench/apps/frappe/frappe/commands/", line 24, in _func ret = f(frappe._dict(ctx.obj), *args, **kwargs) File "/opt/erp7/frappe-bench/apps/frappe/frappe/commands/", line 210, in migrate migrate(context.verbose, rebuild_website=rebuild_website) File "/opt/erp7/frappe-bench/apps/frappe/frappe/", line 31, in migrate frappe.modules.patch_handler.run_all() File "/opt/erp7/frappe-bench/apps/frappe/frappe/modules/", line 29, in run_all if not run_single(patchmodule = patch): File "/opt/erp7/frappe-bench/apps/frappe/frappe/modules/", line 63, in run_single return execute_patch(patchmodule, method, methodargs) File "/opt/erp7/frappe-bench/apps/frappe/frappe/modules/", line 83, in execute_patch frappe.get_attr(patchmodule.split()[0] + ".execute")() File "/opt/erp7/frappe-bench/apps/frappe/frappe/patches/v7_1/", line 5, in execute frappe.rename_doc('DocType', 'Scheduler Log', 'Error Log') File "/opt/erp7/frappe-bench/apps/frappe/frappe/", line 668, in rename_doc return rename_doc(*args, **kwargs) File "/opt/erp7/frappe-bench/apps/frappe/frappe/model/", line 42, in rename_doc update_link_field_values(link_fields, old, new, doctype) File "/opt/erp7/frappe-bench/apps/frappe/frappe/model/", line 155, in update_link_field_values single_doc = frappe.get_doc(field['parent']) File "/opt/erp7/frappe-bench/apps/frappe/frappe/", line 606, in get_doc return frappe.model.document.get_doc(arg1, arg2) File "/opt/erp7/frappe-bench/apps/frappe/frappe/model/", line 49, in get_doc controller = get_controller(doctype) File "/opt/erp7/frappe-bench/apps/frappe/frappe/model/", line 34, in get_controller module = load_doctype_module(doctype, module_name) File "/opt/erp7/frappe-bench/apps/frappe/frappe/modules/", line 184, in load_doctype_module raise ImportError, 'Module import failed for {0} ({1})'.format(doctype, module_name) ImportError: Module import failed for Payment Tool (erpnext.accounts.doctype.payment_tool.payment_tool)

From bench console, try to delete “Payment Tool” using command frappe.delete_doc_if_exists("DocType", "Payment Tool") and then run update again.

I am also facing this issue. Here I am updating directly from 6.23 version to the latest.
As payment Tool is not available in 6.23 version, is the issue because of this.?

I tried frappe.delete_doc_if_exists(“DocType”, “Payment Tool”) from bench console.

but got the response
DoesNotExistError: DocType Deleted Document not found.

Do I need to update directly to V7 first and then V8.?

If that is the case how to do that ?

Thanks for your help.

Check this post How to test new release before upgrading it on production server

You can try to restore your db backup directly in v8.