Erpnext Restore from .sql file

Hi all,

I recently encountered a few errors when trying to backup & restore my site. I backed up one of my site, with .sql, private & public files (in tar.gz).

When i move it to another VM, ran

$ bench --force --site site1.local my/sql/file.sql

got this error

So i tried do directly to database

$ mysql -u root -p root {database name} < import.sql

No error message shown, and when i try to access from web, i got

I checked the database in site_config.json, both database name and password matches

What did i do wrong ?

Thanks

Try running sudo service supervisor restart and sudo service nginx restart.

If that doesn’t get you access, I think you are restoring a develop branch onto master or vice versa.

On both the source and the target machines, go to frappe-bench and cd to apps/frappe and apps/erpnext and run git branch.

If both the source and target machines show either the develop branch each or master branch each, you are fine.

Else, reinstall ERPNext or get another virtual machine and install the same branch on the target machine and try the restore again.

I’m sure there are other possible solutions too.

Trust this helps

Thanks

Jay

Hi @JayRam,

I restarted both supervisor and nginx, but still the same error. And i noticed one more thing,

$ bench drop-site site1.local

gives me this error as well

Not sure about this. Somebody more knowledgeable should be able to chip in soon.

But do try the git branch bit. The underlying problem could be the same: that you are trying to restore a develop branch on master or a master branch on develop.

Thanks

Jay

Hi @JayRam

Thanks for your suggestions, they are everything is in master branch. But i will try to reinstall with the official erpnext & frappe again, since this is my customized version.

I wonder if different version would make a difference. The erpnext i backup with is v7, but slightly older.

Much appreciated!!

Steven

Try running a bench update from the source machine and then do a backup and restore. This will ensure version synchronization between the source and the target systems.

Customizations can definitely break the restore. Try and park all your customizations into an App.

Thanks

Jay

Sorry for asking again, even if the app is customized, shouldnt the backup & restore process be the same?

the only difference is where i use

$ bench new-site site1.local install-app customized_erpnext

I’m not sure why this might break the restore / import sql process

Thanks

Steven

@sjc2929

Are the ERPNext & Frappe versions different, from your site to the VM? If they are, ideally you update to match. I’ve encountered similar issues due to different versions.

Regards
Said

Hi @saidsl @JayRam

Thank you so much, it worked. Bench update definitely helped, as long as they are the same version, i can force restore them.

Much appreciated

Steven