Dave's Brain

Browse - computer tips - howto upgrade postgresql

Date: 2011may25
OS: Linux

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:

        service postgresql initdb		(You have multiple backups, right!)

        service postgresql start

I wish you didn't have to do all this.  Mysql will read previous versions of
the binary data.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, 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.
Advertisements: