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

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

Related

AWS RDS PostgreSQL Upgrade from 9.6.22 to 10.17

Good day. I just finished upgrading my AWS RDS database engine from 9.6.22 to 10.17. I used these steps to make the upgrade using the AWS Console:
Create snapshot of target database to upgrade
Restore snapshot
Upgrade the restored snapshot's (which is now a new instance) DB Engine version.
After I did all of this, everything seems fine but when I access the database, this warning message appears
WARNING: psql major version 9.6, server major version 10.
Some psql features might not work.
I did not continue on my testing because I want to know what is the meaning of this first. Because I am fairly new in AWS as a whole. Thanks!
The meaning is that just because you are connecting to an upgraded database on some machine run by Amazon, the PostgreSQL installation on your local machine was not magically updated. psql from version 9.6 doesn't know what metadata tables were changed in v10, what features were removed and so on.
It would be a good idea to install a more recent version of PostgreSQL on your machine. By the way, upgrading to v10 was not the smartest move, as that version will go out of support in less than a year. You should upgrade to the latest version that your service provider offers.
The client program psql you are using to connect to the database is from an older version than the database it is connecting to. Some of the introspection features might not work. For example, psql from 9.6 won't know how to do tab completion for commands that were added to the server after 9.6.
This is generally not a major problem for psql (unless the server wants to use SCRAM authentication), but for optimal experience it would be good to install a newer client. Other tools like pg_dimp might not with at all against a server newer than they are.

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

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)

rds is running on postgres 9.6.6 while yum update will cause an update of the installed version to 9.6.8

RDS is running on postgres version of 9.6 while my installed version is 9.3.2 and an yum update changes the postgres version to 9.6.8 while my RDS is running on 9.6.6 . Does this version mismatch is bad or should I Upgrade my server RDS from 9.6.6 to 9.6.8
I've done exactly this and it works fine. As you're updating just the client and the client is backwards compatible (especially at such a minor revision level), it should not hurt. A good rule of thumb is to always do regression testing to make sure, and have a way to roll back. There is no rule that says client and server versions have to be identical, however.

PostgreSQL replication between different major versions

AFAIK the documentation states:
In general, log shipping between servers running different major PostgreSQL release levels is not possible. It is the policy of the PostgreSQL Global Development Group not to make changes to disk formats during minor release upgrades, so it is likely that running different minor release levels on primary and standby servers will work successfully. However, no formal support for that is offered and you are advised to keep primary and standby servers at the same release level as much as possible.
But my question is: does disk format actually changes between 9.4.9 and 9.5.6?
We are currently running with:
PostgreSQL 9.4.9 on x86_64-unknown-linux-gnu, compiled by gcc (Debian 4.9.2-10) 4.9.2, 64-bit
Debian GNU/Linux 8.6 (jessie)
And the 'next' possible step would be using the version from this repo:
http://apt.postgresql.org/pub/repos/apt/
Our current DB is about 2TB, so we'd like to try a replication-like approach for a smoother transition, rather tan a using a full pg_dump, which would actually need quite a while with the db frozen.
does disk format actually changes between 9.4.9 and 9.5.6
Yes. Until the coming PostgreSQL 10, PostgreSQL used a wacky version scheme where "x.y" was the "major" version, and the 3rd number was the minor version.
So 9.4 and 9.5 are different major versions. They are definitely not on-disk compatible.
To upgrade you can:
Dump and reload
Use pg_upgrade (the officially recommended way)
Use pglogical
Use Londiste

How to fix pg_dump: aborting because of server version mismatch

My codebase and database is hosted on different servers with Ubuntu 12.04.
database => web1
codebase => web2
I am trying to take my database backup (web1) through the application(web2).
Now the problem is I have different versions of postgres installed on web1 and web2.
pg_dump: server version: 9.3.12 (web1)
pg_dump version: 9.1.23 (web2)
Is there any way I can resolve this issue without upgrading any package because there are multiple applications hosted and relying on these versions.
Thanks for helping!
pg_dump will refuse to connect to a server with a later version than itself for the good reason that it cannot guarantee that it will work.
Downgrading a database from 9.3 to 9.1 is definitely not supported, particularly since version 9.1 is out of support.
You'll have to use pg_dump from the 9.3 installation to dump the database, then you can try to load the result into the 9.1 database. Watch out for errors during restore and test well!
If you are using a SQL Client like Dbeaver and have more than one version of Postgres, remember to change the client version in the option. I was getting this error while using the Dbeaver's backup tool.