Export Insert Data in PostgreSQL

Recently, I was involved a SDN App which is using PostgreSQL database as backend. After finally developing the app and doing upgrades, we stumbled upon the migration scenario where data export of the existing database was needed. Hence I started researching about, how to export data (basically only insert statements) in PostgreSQL.

Though it seemed very every easy to do this from pgAdmin GUI tool, we needed to do it from console due to firewalls and it took us some time to figure out the right command to do it.

PostgreSQL Version: 9.2

Login as postgres admin user

su - postgres

Run the export command below:

.\pg_dump --username "postgres" --format plain --section data --inserts --file "<backup file name>" "<db to backup>"

Hope it helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s