Old database getting restored after bench migrate

bench migrate is causing some problems. It automatically reverts my site to what it was before two days. Why is this happening?

Even after running bench restore when I do bench migrate again same thing happens.

Any help is appreciated. Thanks.


bench restore or bench migrate would never reset your ERPNext site. If you want to perform a clean operation then you will have to run

bench --site <site_name> reinstall

@shreyasp I’ll try to explain more clearly. After running bench update (which includes bench migrate):

  • a Custom Doctype I had earlier deleted comes back.
  • Additionally, I had made changes to a custom Print Format which got reverted to the way they were before 3 days.
  • Nothing happened to the changes I had made to an Item one day ago.
  • I do a bench restore of a backup made before update, and everything is back to normal.
  • After updating again, the Doctype and Print format go back to the way they were.

EDIT: Web Forms I had earlier deleted also come back.

It sounds to me like you are using an old database to restore from.

@cpurbaugh Things go back to normal after restoring. So that’s not the case.

Here’s a gif:

EDIT: I performed git reset --hard on .bench, frappe and erpnext directories but it did not help. I also did bench clear-cache.

@shreyasp Any ideas?


Few assumptions at start,

  1. You are running this in developer mode
  2. Your upstream points to ERPNext and Frappe i.e. https://github.com/frappe/app_name
  3. You haven’t pushed any changes to your repository

Now, If 2nd or 3rd assumption is False, then, every time you have done a bench update changes are getting pulled from the remote branch where you have pushed them.

After deleting the documents from ERPNext, try executing git status on ERPNext and Frappé application folders which should show your deleted documents, which can confirm that deleted documents are being pulled back from the remote.

Thank you so much for this! I added the files to git and reset it. I have little knowledge about git and was very confused as to why this is happening. I’m going to go through this: https://www.codecademy.com/learn/learn-git

Any other suggestions so this doesn’t happen again?