Dave's Brain

Browse - Computer Tips - Postgresql does not keep understand databases from previous versions.

Date: 2011may25
Updated: 2013jan16
OS: Linux
Keywords: postgresql, postgres

Q.  Postgresql does not keep understand databases from previous versions.
How can I upgrade PostgreSQL and keep my data?

A.

Before upgrading:

cd ~postgres pg_dump database1 > database1.sql (for all databases)
(you really should have other backups)
mv /var/lib/pgsql/data /var/lib/pgsql/data.old
... upgrade ... To restore your data after the upgrade:
cd ~postgres createdb database1 (for all databases) pg_restore -d database1 database1.sql
Then in file /var/lib/pgsql/data/pg_hba.conf I like to change "ident sameuser" to "trust"
# Strict local all all ident sameuser
# Slack local all all trust
To start the service:
postgresql-setup initdb (You have multiple backups, right!)
Or on older systems:
service postgresql initdb (You have multiple backups, right!) systemctl start postgresql
Or on older systems:
service postgresql start
I wish you didn't have to do all this. Mysql will read previous versions of the binary data.

Add a comment

Sign in to add a comment
Copyright © 2008-2017, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.