On different computers/servers we have different versions of PostgreSQL installed and can't upgrade all of them yet.

Are there any tools which would allow to convert a database dump from the newer PostgreSQL version to an older one?

  • When going down Postgresql version have to dump using the P option plain sql file. the other option is dump the ttables as CSV and use copy – zsheep Feb 19 at 16:18
  • You can use pg_dump from the older versions. – a_horse_with_no_name Feb 19 at 16:24
  • I tried dumping as plain SQL, but there are still errors when importing to the newer versions related to incrementing of primary keys and others (not the simple CREATE TABLE, INSERT, UPDATE) – Aidas Bendoraitis Feb 19 at 16:31
  • how far back of version are you going to a newer version, can you supply the specific error and sql that causes the error – zsheep Feb 19 at 16:35
  • 1
    that is going back pretty far, there have been significant changes that will break backwards compatibility, There are no flags or options to deal with this. The only option is dump with no data modify the sql file, then dump data only, that should get you around the problem – zsheep Feb 19 at 16:46

Are there tools or options to create a pg_dump file that is compatible to earlier versions of PostgreSQL

No there are no options or tools to create a backwards compatible pg_dump files.

Depending on how far back the version the data needs to be ported to the dump file may work there is no guarantee

A work around this limitation would be run pg_dump using the -P --plain and --schema-only modify the resulting SQL file to make it compatible.

Restore the file.

Then run pg_dump again using -P --plain and -a --data-only options then restore the file.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.