Alternate Strategy to Update ERPNext to current ~v11

Hello friends;

I want to share a few tips from recent experience running upgrades and also how to get to v11 from 9 or 10 easily while importing your data. This is an alternative and works pretty awesome in migrating when simply doing bench update from your current installation; throws you into problems or using bench to restore database into new install is an issue

I will summarize the steps so that if you need to do this we can then get into details right here on the forum.

  1. Backup your database and files: the best method is to use sqldump. start at the frappe-bench folder so its easy to locate your database; use .sql as file extension.
  2. Get your backup out of your server; If you’re on full GUI ubuntu, piece of cake; if you’re on GUI in VM; allow access to copy and paste or drag and drop; or better; allow sftp on port 22 (always available); use Winscp to browse and easily copy files to your local machine. This applies to cloud hosted servers too, WinSCP is an awesome piece of software for easily managing your Ubuntu server instances. Have Putty on hand also.
  3. Install a clean copy of ERPNext, you will get v11 installed this way; I don’t know if at the time of this writing it has been fixed; but normal updates keep you around v10.
  4. Copy over your database to your frappe-bench folder; use WinSCP for convenience. If you have an SSH key, use advanced, select the private key and continue. Blissful.
  5. Restore your database; this is the sweeeeeetest part; the normal restore by bench may fail drastically especially with distant versions. Here’s what to do. if your erpnext db is called erpnextdb (its usually a long alphanumeric name in reality); log into mariadb, don’t use

bench mariadb;

login to mariadb using

mysql -u root -p database-name;

ensure you start at the folder where you uploaded the database or at least know its location. if you don’t know the erpnext db name, then use

mysql -u root -p mysql;

then type

show databases;

at the prompt (include the ; ) then see your erpnext db name; now type

use erpnext-database-name.

Then type

source /home/frappe/frappe-bench/dbbackup.sql.

Mysql nicely and very quickly imports everything in your backup; replacing tables in your fresh database.
6. Your site will now have Internal Server Error: :joy: :smiling_imp: so yes! all good. Now you need to update so the database is fixed. Type banch update. If the update tells you there are changes that need to be committed or discarded (you have modifications); then do

bench update --reset (also you can use git stash against the frappe and erpnext folders at the prompt).

Now things begin to update. You will have errors like NULL issues on some tables, some patches will fail; I personally skip them if I look at them and can live without them; others usually are columns issues in tables which you can alter (POST PROBLEMS ON THIS THREAD AND YOU WILL GET HELP because we can’t know which exact tables may give you issues). I had one with apply_user_permission cannot be null, which I solved with this thread

using
alter table tabDocPerm modify column apply_user_permissions int(1) NULL default 0

I also needed to find the tables with the problem; that’s doable; use the INFORMATION_SCHEMA, as follows:
select * from INFORMATION_SCHEMA.COLUMNS where COLUMN_NAME like '%apply_user_permissions'

On fixing any issue after you have initiated bench update and it has started progressing; use bench migrate to continue. For instance, if like me you find something with GST settings that don’t apply here in my country; I opened the patches.txt file, found in apps/frappe/frappe and app/erpnext/erpnext; I commented the line with a #, saved the file and used

bench migrate

to continue exactly from the last patch. not running the update again.
TIP: to know where a patch has failed from; look at the line just before the python error trace and find something like erpnext.patches..... or frappe.patches... then go to the patches.txt file and edit (use WinSCP; its magical as you can edit the files like a simple notepad file and save; winscp updates on server and you push

bench migrate

and proceed.

I hope this helps; let’s discuss any issues and… Here’s a way to easily get on v11 if you have had difficulties.

BUG noticed so far: After the update some items come up with no data at point of sale. Will update if I find a solution.

5 Likes

Thank you for your contributions. I posted for details to do exactly this a few days ago : (Resolved) Restore V12 from V10 backups

The solutions offerred both here and in my linked post might work fine for the database backups. However, I backed up using ‘…backup …–with files’ option, resulting in files.tar and private-files.tar files.

How do restore the files from version 10 to 11?

Depends on your installation type- cloud, erpnext subscription, linux local machine, or vm; if you have hosted yourself; you can copy the public files tar archive content into the sites public folder at sites/site_name/public/files. If on VM or self-hosted cloud; Extract the tar file and upload using Winscp.

Put the private files in sites/site_name/private/files

I followed all the steps. Database also migrated successfully.
Bench version :
erpnext 12.x.x-develop
frappe 11.1.3

But when adding any customization I am getting the error.

Traceback (most recent call last):
File “/home/nivedita/frappe-bench/apps/frappe/frappe/app.py”, line 61, in application
response = frappe.handler.handle()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/handler.py”, line 21, in handle
data = execute_cmd(cmd)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/handler.py”, line 56, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/init.py”, line 1019, in call
return fn(*args, **newargs)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/init.py”, line 501, in wrapper_fn
retval = fn(*args, **get_newargs(fn, kwargs))
File “/home/nivedita/frappe-bench/apps/frappe/frappe/desk/query_report.py”, line 183, in run
result = get_prepared_report_result(report, filters, dn, user)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/desk/query_report.py”, line 211, in get_prepared_report_result
data = json.loads(uncompressed_content)
File “/usr/lib/python3.5/json/init.py”, line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not ‘bytes’

Kindly help

What type of customization? Script or form?

I have not had this type of error before. Maybe you can post the customization you made and that may help in finding out what the issue is.

This is the problem i am facing

:~/frappe-bench$ bench migrate
Migrating site2
Updating DocTypes for frappe : [========================================]
Updating DocTypes for erpnext : [========================================]
Updating customizations for Address
Traceback (most recent call last):
File “/usr/lib/python3.5/runpy.py”, line 184, in _run_module_as_main
main”, mod_spec)
File “/usr/lib/python3.5/runpy.py”, line 85, in _run_code
exec(code, run_globals)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 97, in
main()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 764, in call
return self.main(*args, **kwargs)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 717, in main
rv = self.invoke(ctx)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/core.py”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/nivedita/frappe-bench/env/lib/python3.5/site-packages/click/decorators.py”, line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/commands/init.py”, line 25, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/commands/site.py”, line 227, in migrate
migrate(context.verbose, rebuild_website=rebuild_website)
File “/home/nivedita/frappe-bench/apps/frappe/frappe/migrate.py”, line 53, in migrate
router.sync_global_search()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/website/router.py”, line 355, in sync_global_search
sync_global_search()
File “/home/nivedita/frappe-bench/apps/frappe/frappe/utils/global_search.py”, line 314, in sync_global_search
value = json.loads(frappe.cache().lpop(‘global_search_queue’))
File “/usr/lib/python3.5/json/init.py”, line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not ‘bytes’

The branch your apps are set to mismatch - frappe is on master while erpnext is on develop.

Try this:

bench switch-to-branch master erpnext --upgrade

For help check these out

https://discuss.frappe.io/search?q=TypeError%3A%20the%20JSON%20object%20must%20be%20str%2C%20not%20%E2%80%98bytes%E2%80%99

please help i am having the same issue.35%20AM

try switch-to-master command

bench switch-to-master

i had to run “bench start” on the first terminal and used the second terminal to run “bench update”

1 Like