P
Prisma2mo ago
iHeyTang

Backup Restore is not work

When I try to use the backup restore function, it only shows the error as shown in the image. How can I solve this problem and successfully complete the restoration?
No description
2 Replies
Prisma AI Help
Prisma AI Help2mo ago
You've gone full bot mode! Let me fetch that AI answer for you ASAP. If your backup restore is failing and you see errors like relation "public.TableName" does not exist or similar, it usually means the tables do not exist in the target database before the data is being restored. This often happens if you use pg_restore with a backup created using the --data-only flag, which only includes data, not the schema (tables, types, etc.)—so the restore process tries to insert data into tables that haven't been created yet. How to solve this: 1. Ensure your backup includes the schema.
When creating a backup with pg_dump, do not use --data-only. Use the custom format (-Fc) to include both schema and data:
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

Import data from an existing database 2. Restore using pg_restore with schema and data:
Use the following command to restore:
PGSSLMODE=disable \
pg_restore \
-h 127.0.0.1 \
-p 5432 \
-v \
-d postgres \
./db_dump.bak \
&& echo "-complete-"

PGSSLMODE=disable \
pg_restore \
-h 127.0.0.1 \
-p 5432 \
-v \
-d postgres \
./db_dump.bak \
&& echo "-complete-"

Make sure you are connected to your Prisma Postgres instance via the @prisma/ppg-tunnel if required 3. Import data into Prisma Postgres. 3. If you already restored only data:
- First, run your Prisma migrations to create the schema:
npx prisma migrate deploy

npx prisma migrate deploy

- Then, restore the data. 4. If you see errors about missing tables or relations:
- Double-check that the schema exists in the target database before restoring data. - If you see errors about configuration parameters (like transaction_timeout), ensure your PostgreSQL versions are compatible. Summary:
Always back up and restore both schema and data, and ensure the schema exists befor e restoring data. If you missed running migrations, do so before restoring data. This should resolve the errors you are seeing during restore operations. Related issue and solution 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Nurul
Nurul2mo ago
This was fixed last Saturday. Please let us know in case you continue to see any issues.

Did you find this page helpful?