Postgresql – Change Linux Family for Postgres Database

linuxpostgresql

I have Postgres 9.5 running on "old" Debian server and about to move it on "new" CentOS, so here is the question.
Is it OK to just install binaries of the same 9.5 version and just copy database cluster (PGDATA) to a new server?

Best Answer

The immediate problem you are going to hit is that there will be a different version of the C library, and your collations will change. So, unless you are using the C collation, either move the database with pg_dumpall/restore or , if you copy the data directory, REINDEX all indexes that are defined on columns with a string data type.

Also make sure that both systems are either 32-bit or 64-bit when copying the data directory.

And upgrading PostgreSQL is not a "tricky political enterprise-world question". After all, PostgreSQL doesn't get any money if you upgrade. If you are not running a supported release, you won't get updates, so you will be exposed to data corruption bugs.

Of course you want to have the same release as the client. Your task is to drive the danger home to the customer.