Database Backup v12 to v13

can i apply the database backup sql file (downloaded from ERP backup feature) of v12 to v13? Will it cause problem or i will have all my data / customizations moved to v13 this way?

No, there are database schema differences between v12 and v13. You cannot restore a V12 onto a v13 database.

You will have to upgrade, or perform a manual data migration.

I thought so :frowning: Thanks for the confirmation!!

I have migrated v12 database to v13 a couple of times including just 24hrs ago when I did some tests. Backups restore without issues for me.

The restore will certainly succeed. The mysqldump tool is designed to cleanly restore over an existing database. It’s essentially a huge text file, that contains these statements:

  • DROP TABLE tabCustomer
  • CREATE TABLE tabCustomer <schema>
  • INSERT INTO TABLE tabCustomer <rows of data>

This repeats for all SQL tables. It will always succeed. Because each Table is completely dropped, then recreated, before rows are inserted from the backup.

But there will be mistakes and problems. Here are some examples:

  • Assume in v12, the Customer DocType (SQL name tabCustomer), has a field named foo
  • Assume in v13, the developers decided to rename this to bar

When you restore the v12 backup, the entire Customer table is deleted (SQL DROP). It is rebuilt and populated from v12. The field in Customer will now have the old, legacy name: foo

Problem #1: All the v13 Python and JS code will be expecting the new name: bar. The code will not refer to foo anymore. This may cause errors. Of course, to get those errors, you must interact with Customers in your web browser. You must do something that calls code which references bar, which will not exist in SQL.

Now, you might be able to fix the error by running a bench migrate command. This command tries to synchronize the schema. It might notice that Customer table is missing SQL field bar. So it will create it for you.

However. This will lead to a new problem…

Problem 2: The bench migrate command does not delete existing, legacy columns. It only creates missing columns. When its finished, both field foo and field bar will exist in the SQL table.

However…the historic values of foo (from your backups) are not automatically copied into bar. The bench migrate command isn’t that smart. Only an Upgrade can handle that migration (by executing patch files).

So you’ll have data in column foo. But ERPNext will never read it. And you will have a column named bar. But it will be 100% empty.

Proceed at your own risk.

Perhaps later when I have time, I will do a schema comparison between v12 and v13, and try to find a real-world example.

@brian_pond i am thinking of migrating from v12 to v13 but there are major changes
like the project template in v12 is different than v13 project template will it work if i just restore. not just in here but there can be such cases in other doctypes.

I have not compared v12 and v13 Project schema. So I am not sure the differences.

I do not recommend restoring SQL databases from v12 to v13. Do a true upgrade instead, using Bench.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.