migration of existing db to Prisma Postgress

I have an existing database (Postgress) that i would like to move to your Prisma postgress. I would like to backup (old db) and restore (to new db) the db. Is it possible? If yes, how? If no, how can i proceed? Thanks
4 Replies
Prisma AI Help
You chose to compile with the bot. One moment while I piece together your answer… Yes, it's definitely possible to migrate your existing PostgreSQL database to Prisma Postgres. You can accomplish this through a backup and restore process using standard PostgreSQL tools. Here's how to do it: Migration Process You can migrate your existing PostgreSQL database to Prisma Postgres in three main steps: 1. Create a new Prisma Postgres database 2. Export your existing data using pg_dump 3. Import the data into Prisma Postgres using pg_restore 1. Create a new Prisma Postgres database First, you'll need to create a new Prisma Postgres database: 1. Log in to the Prisma platform and open the Console 2. In a workspace, click the "New project" button 3. Name your project (e.g., "hello-ppg") 4. In the "Prisma Postgres" section, click "Get started" 5. Select the region closest to you 6. Click "Create project" Once provisioned, save your Prisma Postgres connection URL for later use. 2. Export data from your existing database Use pg_dump to export your existing PostgreSQL database:
pg_dump \
-Fc \
-v \
-d __DATABASE_URL__ \
-n public \
-f db_dump.bak
pg_dump \
-Fc \
-v \
-d __DATABASE_URL__ \
-n public \
-f db_dump.bak
Replace __DATABASE_URL__ with your actual database connection URL. 3. Import data into Prisma Postgres To import your data: 1. Set up a TCP tunnel to your Prisma Postgres database:
export DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=__API_KEY__"
npx @prisma/ppg-tunnel --host 127.0.0.1 --port 5433
export DATABASE_URL="prisma+postgres://accelerate.prisma-data.net/?api_key=__API_KEY__"
npx @prisma/ppg-tunnel --host 127.0.0.1 --port 5433
2. In a separate terminal, restore your backup:
PGSSLMODE=disable \
pg_restore \
-h 127.0.0.1 \
-p 5433 \
-v \
-d postgres \
./db_dump.bak \
&& echo "-complete-"
PGSSLMODE=disable \
pg_restore \
-h 127.0.0.1 \
-p 5433 \
-v \
-d postgres \
./db_dump.bak \
&& echo "-complete-"
You can then verify the import worked using Prisma Studio. For more detailed instructions, check out the Import from existing database guide.
If you're considering migrating your database to Prisma Postgres for a production environment or have more compl
ex migration needs, it might be helpful to reach out to the Prisma Team who can provide personalized guidance for your specific use case.
Nurul
Nurul2w ago
Hey @Markigno 👋 Let us know in case you still need any help?
Markigno
MarkignoOP2w ago
@Nurul (Prisma) the data migration is not an easy process... i can't use my DATABASE_URL on old db because it contains certificates, so i have to change db config before starting the process. for develop env it was possible, in the prod env no. I have to test the migration a couple of times before going live... to test it i have everytime to erase the db and it is not possible, i have to drop the db and restart the environment creation... i mean, the Prisma DB service is very good, but the migration of the data needs to be improved...
Nurul
Nurul5d ago
Thank you for sharing the feedback with us 🙏

Did you find this page helpful?