How do I take restore a back up of database in PostgreSQL 9.6 into PostgreSQL 12.2? - postgresql

I am trying to upgrade my database
from PostgreSQL 9.6 to PostgreSQL 12.2
using pg_dump/pgrestore method.
I've already tried dumping data from older version using pg_dump12.
(As pgdump and pgrestore are compatible only with same major version)

Related

How can i upgrade postgresql version without dump and restore the DBs?

in the past i upgraded postgresql server from 9.3 to 9.6 version in this way:
(dump all the DBs)
apt-get install postgresql-9.6 postgresql-contrib-9.6
pg_dropcluster 9.6 main --stop
pg_upgradecluster 9.3 main
pg_dropcluster 9.3 main
And then, i relaunched the initdb, recreated the databases and restored with the previous dumps.
now i want to upgrade from 9.6 to 10 or major.
Is there a way to do this without dump all the DBs and then restore them?
Thanks in advance
Duplicate: How to upgrade PostgreSQL from version 9.6 to version 10.1 without losing data?

Can I do a hard upgrade of a PostGIS-enabled database without the old PostGIS binaries?

I want to upgrade a database that was created in Postgresql 10 & PostGIS 2.4 to Postgresql 11 & PostGIS 2.5. However, due to Homebrew constantly updating, I do not have the old Postgres/PostGIS database installed on my MacOS 10.14 system anymore.
As asked in this question and discussed in this answer and also my own, upgrading a PostGIS-enabled PostgreSQL database requires a Hard Upgrade. In other words, dump the old database and restore it with a special PostGIS script.
However, I now find myself in a situation where I could install the old PostgreSQL 10 with brew install postgresql#10, but not PostGIS, because Homebrew has no more PostGIS 2.4 formula. Therefore, pg_dump will terminate with:
[26040] ERROR: could not access file "$libdir/postgis-2.4": No such file or directory
Is there another way to upgrade an older PostGIS-enabled database?
Update
The brew install postgis installation is not recognizsed by the old postgres (postgres#10) version. Therefore, I cannot simply upgrade PostGIS, as suggested in the comments.
ALTER EXTENSION postgis UPDATE
ERROR: could not open extension control file "/usr/local/Cellar/postgresql#10/10.6_1/share/postgresql#10/extension/postgis.control": No such file or directory
I ended up using an older version of the Postgress.app, which offers the option to use PostgreSQL 10.7 & PostGIS 2.4.6. From there I can use the older binaries in /Applications/Postgres.app/Contents/Versions/10/bin.

Can you upgrade Postresql-server directly from 9.2 to 9.6?

Can you upgrade Postresql-server directly from 9.2 to 9.6? (Running on RHEL 7)
yes:
https://www.postgresql.org/docs/9.6/static/pgupgrade.html
pg_upgrade supports upgrades from 8.4.X and later to the current major
release of PostgreSQL, including snapshot and alpha releases.
https://www.postgresql.org/docs/9.6/static/app-pgdump.html
Because pg_dump is used to transfer data to newer versions of
PostgreSQL, the output of pg_dump can be expected to load into
PostgreSQL server versions newer than pg_dump's version. pg_dump can
also dump from PostgreSQL servers older than its own version.
(Currently, servers back to version 7.0 are supported.) However,
pg_dump cannot dump from PostgreSQL servers newer than its own major
version; it will refuse to even try, rather than risk making an
invalid dump.
ephasis mine

How to upgrade PostgreSQL from version 9.1 to version 9.5 without losing data?

I'm using the PostgreSQL database for my OPEN ERP application (on Ubuntu 12.04
LTS).
Are there any detailed instructions on how to upgrade PostgreSQL database?

Using pg_dump files from 9.3 on 9.5

Before migrating from an old laptop I created dumpfiles for all of my postgresql/postgis databases using pg_dump. However after migrating I'm having problems with a lot of errors on import to the new database. I've realized that my old and new machine are running different versions of postgresql/postgis. The dumps were created on a machine running postgresql 9.3.13 and postgis version 2.1; I'm trying to recreate the databases on a machine running postgresql 9.5.4 and postgis version 2.2
Any suggestions for getting the data from my dumps to load without problems? Or for creating new dumps on the old machine which will work across versions?