I have two PostgreSQL databases on my development server, one I use for development and another for production where I test my web applications. When I was using an earlier version of PostgreSQL I was able to easily create a TAR dump file of my prod database in pgAdmin and use that same TAR file to restore my development database after selection the option to clean the database first. A while back I upgraded pgAdmin to the version (1.20.0 I think) that is supposed to work with PostgreSQL 9.4. For whatever reason I cannot restore files in that version. I have tried TAR and SQL but the restore button is always protected.
I decided to use pg_dump
and create a SQL file with only insert statements for my production database data. What I want to do is replicate what I was able to do in pgAdmin: Clean my development database and load my pg_dump
SQL file into it.
I've search but so far I have not found any examples of how to do this in pgAdmin or in the terminal.
INSERT
statements for your dumps (unless you have only a small amount of data).COPY
is virtually always (much) faster. Furthermore, as I understand it, you need to use the--clean
option of eitherpg_dump
orpg_restore
, depending on which dump format you choose. It will throw away your tables before recreating them, so you need to do a full backup (not data-only).