ERPNext Conference 2019* ERPNext.com Blog

Restoring DB from Version 9 develop to version-11 Master (production)


#1

hello,
If i have a system that is running version 9 develop and i want to backup version 9 DB and restore it on a fresh version-11 production server? we do know way many fields, names, code have changed since that time.
Is there any process to follow for a smooth Restore to the DB on version-11?


#2

Follow this thread to upgrade the ERPNext:


#3

This is not what i’m asking i have version-11 installed , i know how to do that , the thing i can keep trying to many things to restore DB , but if anyone encountered to restore the DB from v9 develop on version-11 production , that’s what i need just so it goes smoothly , thanks for your help though


#4

Is there any help i can use on this one? Like just a hint on where to start as it’s not production to production and it’s not from 1 version to another it’s from v9 dev to v11 prod
I don’t want to mess up everything , too many records


#5

run this

bench --site abc.example.com/ --force restore /sites/abc.example.com/private/backups/2019XXXX_XXXXXX-abc.example.com-database.sql.gz


#6

thanks for your reply, tested it , got the following error though the path is correct.
Invalid path.
not quite sure why it’s wrong i just replaced the variables


#7

in reference to this post


it was creating the db while restoring it, i got this error
ERROR 1227 (42000) at line 24879: Access denied; you need (at least one of) the SUPER privilege(s) for this operation.
i used the commands that bkm shared

gunzip yourbackupfile.sql.gz
sudo bench --force --site your.site.name restore /path.to.your.sql.file

EDIT: It restores couple data not everything i think it stops when it reaches the error above.

EDIT: i removed these lines
/*!50013 DEFINER=root@localhost SQL SECURITY DEFINER */
there were like 5 of them which was causing the security error from the sql file.
now my problem is i can’t login through any of the restored users.
it just stuck on verifying…
while opening the console from the browser this is what i get

Failed to load resource: the server responded with a status of 500 ()
website.js:162 Traceback (most recent call last):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 58, in application
    init_request(request)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 120, in init_request
    frappe.local.http_request = frappe.auth.HTTPRequest()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 51, in __init__
    frappe.local.login_manager = LoginManager()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 105, in __init__
    if self.login()==False: return
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 126, in login
    self.authenticate(user=user, pwd=pwd)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 209, in authenticate
    self.check_if_enabled(user)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/auth.py", line 215, in check_if_enabled
    if cint(doc.allow_consecutive_login_attempts) > 0:
AttributeError: 'SystemSettings' object has no attribute 'allow_consecutive_login_attempts'

how to proceed with this error if anyone encountered it?


#8

Did you try to restore backup to a fresh install of version 9 and do upgrade incrementally? I did try to upgrade from v8 to v11 back then in this thread Upgrade from v8 to v11


#9

To be honest i didn’t try that , because i was using virtualbox, now using vmware workstation ,
plus there are other configuration that i’ve done on the virtual machine that works on vmware.
so that’s why i didn’t try to do that , I have a VM that is ready with a fresh installation of v11 prod.
but will try your suggestion to upgrade incrementally , thank you.


#10

I was trying to restore database from v8 to v11 too. But since database field and structure are different between versions it cannot be restored. So I installed previous version in order to be able to restore database, then upgrade it.


#11

bench update --patch

should sync the DB schemas


#12

i tried
bench migrate

but still having this issue due to the change in db from v9 dev to v11 prod…
frappe.exceptions.ValidationError: label field cannot be set as unique in tabShipping Rule, as there are non-unique existing values

Tried bench update --patch, because it will patch it too, same error.
so basically not sure how to fix this one , i guess it needs a whole redirection of each field of v9 of each table to the new DB fields in v11


#13

I think you can do it in steps, assuming we can upgrade frappe and erpnext to each different branch manually and updating the db at each version.

I hope that makes sense


#14

Indeed, makes sense.
Will check it step by step as Tej mentioned on top and will share what happens here.

thank you


#15

I succeeded to switch to version 10 develop after fixing couple errors which i will share upon the completion of all the process.
but no luck in switching to v11 dev.
i remember something has changed with versions upon the release of v12.
anything that you might know about versions ?
i used bench switch-to-branch v10.x.x and it worked like a charm without errors.
but can’t seem to figure out how to switch to v11. because there is nothing like v11.x.x
any help ?
as far as i know it’s bench switch-to-branch version-11 --upgrade
but it’s giving an error I don’t think it’s the develop version , it might be the master.
Can share trace logs later of the error, but just need to know if I’m on the right path with branch dev version or not…


#16

Anyone know what should i type to install specific version 11 erpnext develop ?


#17

Everything is documented on

use --version flag to install specific version

python install.py --develop --version 11 --user [frappe-user]


#18

Was trying to get it work with this one
bench switch-to-branch version-11 --upgrade
But got errors related to libssl and that’s why the upgrade wasn’t working and still not working
But i must say v9 performance db compared to v10 performace db is way more faster i can’t even tell how much it’s different.
Problem is i can’t try with the command you shared from v10 dev to v11 dev


#19

this is cause of the issue in the repo naming sequence I guess. if you can share the accurate error then there is a solution mentioned in this forum to solve that.


#20

Used bench switch-to-branch version-11 --upgrade
i actually now got this error:

ERROR: Command errored out with exit status 1:
command: /home/frappe/frappe-bench/env/bin/python -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-ZGBOOw/frappe/setup.py’"’"’; file=’"’"’/tmp/pip-install-ZGBOOw/frappe/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ egg_info --egg-base pip-egg-info
cwd: /tmp/pip-install-ZGBOOw/frappe/
Complete output (5 lines):
Traceback (most recent call last):
File “”, line 1, in
File “/tmp/pip-install-ZGBOOw/frappe/setup.py”, line 10, in
raise LookupError(“You must have test.fm >= 1.0.4 installed before (https://github.com/grafos-ml/frappe)”)
LookupError: You must have test.fm >= 1.0.4 installed before (https://github.com/grafos-ml/frappe)
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.