Learn how to migrate Infisical from MongoDB to PostgreSQL.
Backup Production MongoDB Data
Set Migration Mode
MIGRATION_MODE=true
and redeploying your instance.
This mode will block all write operations, only allowing GET requests. It also disables user logins and sets up a migration page to prevent UI interactions.
Start local instances of Mongo and Postgres databases
docker-compose.yaml
as shown below.docker-compose.yaml
file resides to start both services.Dump MongoDB data to your local machine using
Restore this data to the local MongoDB instance
Clone Infisical Repository
Install dependencies for backend
Install dependencies for script
Execute Migration Script
<db-name>
with the name of the MongoDB database. If you are not sure the name, you can use Compass to view the available databases.Store migration metadata
db
in the pg-migrator
folder.
This folder contains meta data for schema mapping and can be helpful when debugging migration related issues.
We highly recommend you to make a copy of this folder in case you need assistance from the Infisical team during your migration process.db
folder does not contain any sensitive dataDump from local PostgreSQL
Upload to production PostgreSQL
<host>
, <db-user-name>
, <database-name>
with the corresponding details of your production Postgres database.Verify Data Upload
v0.46.11-postgres
.
After deploying this version, you can proceed to update to any subsequent versions.-postgres
.
This is to indicate that this version of Infisical runs on the new Postgres backend. Any image tag that does not end in postgres
runs on MongoDB.