1

I do a pg_dump from RDS, this dump need to restore en local develop context

psql -U postgres -d devDDB -f /tmp/prodDDBB.sql

and too many errors jump, like:

psql:/tmp/prodDDBB.sql:123255: ERROR: duplicate key value violates unique constraint "operation_keys_pkey"
DETAIL: Key (id)=(1088) already exists.
psql:/tmp/prodDDBB.sql:226882: ERROR: relation "brands_vehicles_account_index" already exists

this is normal on a restore operation? the database already exist, i guess this s normal.

nbk
8,6996 gold badges15 silver badges27 bronze badges
asked Nov 10, 2020 at 14:56

1 Answer 1

1

use

-c
--clean

Output commands to clean (drop) database objects prior to outputting the commands for creating them. (Unless --if-exists is also specified, restore might generate some harmless error messages, if any objects were not present in the destination database.)

This option is only meaningful for the plain-text format. For the archive formats, you can specify the option when you call pg_restore.

see manual

so that all elemenst are dropped before you restore the database.

in your case use pg_restore with the same parameter, that has the same effect

answered Nov 10, 2020 at 17:12
3
  • @JorgeMansoN please accept te answer if it was helpful Commented Nov 11, 2020 at 15:24
  • i still can't vote, but i can accept the solution Commented Nov 11, 2020 at 15:33
  • you need 15 rep for that, keep up and you will quickly reach it Commented Nov 11, 2020 at 16:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.