Postgresql database recovery

Do I always need to delete and then create a database to restore it from the pg_dump file? If I do not delete the database, the restored data is added to the current data in the database, even if some register is already in the database (so the data is duplicated).

+5
source share
1 answer

You can use the -c (--clean) option while pg_dump is running, so the dump will contain the correct DROP commands ...

But overall, I would suggest going the "hard way":

dropdb ...
createdb ...
psql -d ... -f dump.file

Thus, you are sure that there are no "left frames" from what was previously in the database.

+6
source

All Articles