Migrating to a new server with different plugins
Discussed in https://github.com/inventree/InvenTree/discussions/9838
Originally posted by flborn June 24, 2025 I had installed the InventreeBulkPlugin for testing purposes on a production instance. However, I don't need it.
Now I wanted to move to another server and would do these steps:
- Create Backup on the current instance
- Setup new instance with all needed plugins
- Restore Backup on new instance
Since the BulkPlugin made alterations to the database, the restore process fails with an error message that certain relationships are not present on the new DB instance.
My next try was to remove the plugin on the current instance, but a plugin can only be deactivated, not removed. And most certainly the DB alterations are not removed either.
Is there a way to restore the backup on the new instance without installing the bulkplugin? (BTW: I tried that as well and installation process fails, the plugin cannot be activated, and migrations are also not executed)
# Version Information:
InvenTree-Version: 0.17.14
Django Version: 4.2.17
Commit Hash: bca375d
Commit Date: 2025-06-22
Database: postgresql
Debug-Mode: False
Deployed using Docker: True
Platform: Linux-6.8.0-58-generic-x86_64-with
Installer: DOC
Active plugins:
[
{'name': 'InvenTreeBarcode', 'slug': 'inventreebarcode', 'version': '2.1.0'},
{'name': 'InvenTreeCoreNotificationsPlugin', 'slug': 'inventreecorenotificationsplugin', 'version': '1.0.0'},
{'name': 'InvenTreeCurrencyExchange', 'slug': 'inventreecurrencyexchange', 'version': '1.0.0'},
{'name': 'InvenTreeLabel', 'slug': 'inventreelabel', 'version': '1.1.0'},
{'name': 'InvenTreeLabelMachine', 'slug': 'inventreelabelmachine', 'version': '1.0.0'},
{'name': 'InvenTreeLabelSheet', 'slug': 'inventreelabelsheet', 'version': '1.0.0'},
{'name': 'DigiKeyPlugin', 'slug': 'digikeyplugin', 'version': '1.0.0'},
{'name': 'LCSCPlugin', 'slug': 'lcscplugin', 'version': '1.0.0'},
{'name': 'MouserPlugin', 'slug': 'mouserplugin', 'version': '1.0.0'},
{'name': 'TMEPlugin', 'slug': 'tmeplugin', 'version': '1.0.0'},
{'name': 'KiCadLibraryPlugin', 'slug': 'kicad-library-plugin', 'version': '1.4.3'},
{'name': 'SupplierCart', 'slug': 'suppliercart', 'version': '0.4.0'
}
]
@flborn can you please provide:
- The sequence of commands you are running
- Full error logs / output
I am not sure this an InvenTree bug per-se. AppMixins might add migrations that affect the schema - such, making a restore to a DB without these changes (ie tables and migration records) impossible. In the current system, I do not think it is possible to transfer a DB from an instance with a schema change to a one without that schema change. The new instance would be missing the required data structures to load data into.
To enable something like this, we would need to adapt the backup mechanisms and optionally include some information about the system on which the backup was made (environment variables, secretes, versions and build metadata, plugins and plugin states). That would be a bit of work but also have some nice options to address https://github.com/inventree/InvenTree/issues/4206 and https://github.com/inventree/InvenTree/issues/5713
Extending the warning in the docs should also be a first step
Database Version
When performing backup and restore operations, it is imperative that you are running from the same installed version of InvenTree. Different InvenTree versions may have different database schemas, which render backup / restore operations incompatible. https://docs.inventree.org/en/stable/start/backup/#data-backup
It's a difficult problem to address either way.. I think our options are, in very broad terms
It's not possible
- Update documentation to say that "backup / restore" is not possible if you have plugins which add tables
Exclude Plugin Tables
- When performing backup/restore (or import/export), somehow exclude any tables which are defined by plugins
Include Plugin Tables
- Extend backup mechanism to look for plugin tables
Additionally, we probably need to consider how to remove tables created by plugins, when those plugins are uninstalled (this could be an optional step if the user wants to keep those tables for some reason)
Workflow
Both servers are running in a docker environment. I'll refer to them as current and new.
current:inventree-server- creating backup viainvoke backupnew- setting up a new instance 2.1.new-docker compose run --rm inventree-server invoke update2.2.new-docker compose run inventree-server invoke superuser2.3.new- installing wanted plugins, with server restarts andinvoke updatecmds- copying backup from
currenttonew new-invoke restore <backupfile>
Additionally, we probably need to consider how to remove tables created by plugins, when those plugins are uninstalled (this could be an optional step if the user wants to keep those tables for some reason)
I would see this as a viable option. If you want to migrate to a different server you will most probably have the same setup. The point which is preventing it now for me is that I don't want a certain plugin, because it's not used. If a plugin could be removed along with it's DB migrations, I don't see any problems. You remove everything unwanted from the current server, and then start the backup.
That's probably the wrong issue to note that, but with the current version 0.17.14 I cannot even install the inventree-bulk-plugin.
So effectively I cannot move to a different server. I'll try removing the relations in the backup by hand.
Broken plugins will make a server migration pretty tedious.
FYI: The idea with cleaning up the tables is already tracked here