Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Postgres 9.1 to 9.2 upgrade guide for Ubuntu 12.04
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
sudo apt-get install postgresql-9.2 postgresql-server-dev-9.2 postgresql-contrib-9.2
sudo su -l postgres
psql -d template1 -p 5433
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
service postgresql stop
/usr/lib/postgresql/9.2/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin -B /usr/lib/postgresql/9.2/bin -d /var/lib/postgresql/9.1/main/ -D /var/lib/postgresql/9.2/main/ -O "-c config_file=/etc/postgresql/9.2/main/postgresql.conf" -o "-c config_file=/etc/postgresql/9.1/main/postgresql.conf"
logout # logout postgresql back to previous user
sudo apt-get remove postgresql-9.1
sudo vim /etc/postgresql/9.2/main/postgresql.conf # change port to 5432
sudo service postgresql restart
@agnivade

This comment has been minimized.

Show comment Hide comment
@agnivade

agnivade Apr 12, 2013

This is perfect. Worked without any hiccups on production. Thanks!

This is perfect. Worked without any hiccups on production. Thanks!

@rasheedamir

This comment has been minimized.

Show comment Hide comment
@rasheedamir

rasheedamir May 26, 2013

Thanks it worked perfectly fine!

Thanks it worked perfectly fine!

@ovidiuvisan

This comment has been minimized.

Show comment Hide comment
@ovidiuvisan

ovidiuvisan Jun 19, 2013

Flawless! Thank you!

Flawless! Thank you!

@shark300

This comment has been minimized.

Show comment Hide comment
@shark300

shark300 Jun 28, 2013

Thank you!

Thank you!

@guivinicius

This comment has been minimized.

Show comment Hide comment
@guivinicius

guivinicius Jul 5, 2013

Great. Thank you!

Great. Thank you!

@jwarzech

This comment has been minimized.

Show comment Hide comment
@jwarzech

jwarzech Jul 10, 2013

Thanks!

Thanks!

@mbnoimi

This comment has been minimized.

Show comment Hide comment
@mbnoimi

mbnoimi Jul 16, 2013

This line doesn’t work

CREATE EXTENSION IF NOT EXISTS hstore;

It gives this error message:

template1=# CREATE EXTENSION IF NOT EXISTS hstore;
ERROR:  could not open extension control file "/usr/share/postgresql/9.2/extension/hstore.control": No such file or directory
template1=#

mbnoimi commented Jul 16, 2013

This line doesn’t work

CREATE EXTENSION IF NOT EXISTS hstore;

It gives this error message:

template1=# CREATE EXTENSION IF NOT EXISTS hstore;
ERROR:  could not open extension control file "/usr/share/postgresql/9.2/extension/hstore.control": No such file or directory
template1=#
@frootloops

This comment has been minimized.

Show comment Hide comment
@frootloops

frootloops Jul 17, 2013

Thank you!

Thank you!

@barakargaman

This comment has been minimized.

Show comment Hide comment
@barakargaman

barakargaman Aug 25, 2013

thanks!

thanks!

@hunterowens

This comment has been minimized.

Show comment Hide comment
@hunterowens

hunterowens Sep 4, 2013

This no longer work on 12.04 LTS.

E: Package 'postgresql-9.2' has no installation candidate

This no longer work on 12.04 LTS.

E: Package 'postgresql-9.2' has no installation candidate

@AiOO

This comment has been minimized.

Show comment Hide comment
@AiOO

AiOO Sep 6, 2013

This worked fine on ubuntu 12.04 :)

AiOO commented Sep 6, 2013

This worked fine on ubuntu 12.04 :)

@kivikakk

This comment has been minimized.

Show comment Hide comment
@kivikakk

kivikakk Sep 13, 2013

Worked well for upgrading 9.0 to 9.3, too.

Worked well for upgrading 9.0 to 9.3, too.

@revathskumar

This comment has been minimized.

Show comment Hide comment
@revathskumar

revathskumar Sep 17, 2013

Can any one explain me the what line no. 10 do?

Can any one explain me the what line no. 10 do?

@as181920

This comment has been minimized.

Show comment Hide comment
@as181920

as181920 Sep 20, 2013

worked well for upgrading 9.1 to 9.3 on ubuntu server 12.04 LTS
Thanks a lot

worked well for upgrading 9.1 to 9.3 on ubuntu server 12.04 LTS
Thanks a lot

@ntucker

This comment has been minimized.

Show comment Hide comment
@ntucker

ntucker Sep 25, 2013

How do I get 9.3?

ntucker commented Sep 25, 2013

How do I get 9.3?

@montogeek

This comment has been minimized.

Show comment Hide comment
@montogeek

montogeek Oct 26, 2013

Very much thanks Sir!

Very much thanks Sir!

@nonintanon

This comment has been minimized.

Show comment Hide comment
@nonintanon

nonintanon Oct 30, 2013

Thank you :)

Thank you :)

@scarver2

This comment has been minimized.

Show comment Hide comment
@scarver2

scarver2 Dec 5, 2013

Worked great for upgrading 9.2 -> 9.3 also

@ntucker Follow these directions to upgrade PostgreSQL 9.3 on Ubuntu http://wiki.postgresql.org/wiki/Apt

scarver2 commented Dec 5, 2013

Worked great for upgrading 9.2 -> 9.3 also

@ntucker Follow these directions to upgrade PostgreSQL 9.3 on Ubuntu http://wiki.postgresql.org/wiki/Apt

@petere

This comment has been minimized.

Show comment Hide comment
@petere

petere Dec 12, 2013

You should be looking into using pg_upgradecluster. It's much easier than this.

petere commented Dec 12, 2013

You should be looking into using pg_upgradecluster. It's much easier than this.

@pecha7x

This comment has been minimized.

Show comment Hide comment
@pecha7x

pecha7x Jan 14, 2014

Worked perfect for 9.1 -> 9.3
Thanks!

pecha7x commented Jan 14, 2014

Worked perfect for 9.1 -> 9.3
Thanks!

@simeonwillbanks

This comment has been minimized.

Show comment Hide comment
@simeonwillbanks

simeonwillbanks Feb 3, 2014

👍

👍

@mleszcz

This comment has been minimized.

Show comment Hide comment
@mleszcz

mleszcz Feb 12, 2014

A bit easier way:

Add apt.postgresql.org repository by running this script: http://anonscm.debian.org/loggerhead/pkg-postgresql/postgresql-common/trunk/download/head:/apt.postgresql.org.s-20130224224205-px3qyst90b3xp8zj-1/apt.postgresql.org.sh

sudo apt-get install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2
su postgres
pg_ctlcluster 9.1 main stop
pg_ctlcluster 9.2 main stop
pg_dropcluster 9.2 main
pg_upgradecluster 9.1 main
pg_ctlcluster 9.2 main start
CTRL-D to quit su postgres
sudo apt-get remove postgresql-9.1

mleszcz commented Feb 12, 2014

A bit easier way:

Add apt.postgresql.org repository by running this script: http://anonscm.debian.org/loggerhead/pkg-postgresql/postgresql-common/trunk/download/head:/apt.postgresql.org.s-20130224224205-px3qyst90b3xp8zj-1/apt.postgresql.org.sh

sudo apt-get install postgresql-9.2 postgresql-client-9.2 postgresql-contrib-9.2 postgresql-server-dev-9.2
su postgres
pg_ctlcluster 9.1 main stop
pg_ctlcluster 9.2 main stop
pg_dropcluster 9.2 main
pg_upgradecluster 9.1 main
pg_ctlcluster 9.2 main start
CTRL-D to quit su postgres
sudo apt-get remove postgresql-9.1

@Kulgar

This comment has been minimized.

Show comment Hide comment
@Kulgar

Kulgar Feb 24, 2014

The gist worked fine to upgrade from 9.1 to postgresql 9.3!
Thanks a lot!

Kulgar commented Feb 24, 2014

The gist worked fine to upgrade from 9.1 to postgresql 9.3!
Thanks a lot!

@bernardeli

This comment has been minimized.

Show comment Hide comment
@bernardeli

bernardeli Mar 7, 2014

Awesome, thanks.

Awesome, thanks.

@vdolgishev

This comment has been minimized.

Show comment Hide comment
@vdolgishev

vdolgishev Apr 1, 2014

Thanks a lot! You saved my time!

Thanks a lot! You saved my time!

@ibussieres

This comment has been minimized.

Show comment Hide comment
@ibussieres

ibussieres Apr 24, 2014

I did it this way (for 9.3), in an automated fashion.

https://gist.github.com/ibussieres/11262268

I did it this way (for 9.3), in an automated fashion.

https://gist.github.com/ibussieres/11262268

@borgesalkan

This comment has been minimized.

Show comment Hide comment
@borgesalkan

borgesalkan Apr 25, 2014

Thanks @ibussieres. Upgraded to 9.3.

Thanks @ibussieres. Upgraded to 9.3.

@lukaszbudnik

This comment has been minimized.

Show comment Hide comment
@lukaszbudnik

lukaszbudnik May 22, 2014

Perfect! Works like a charm.

Perfect! Works like a charm.

@syadlowsky

This comment has been minimized.

Show comment Hide comment
@syadlowsky

syadlowsky Jun 3, 2014

Thanks!

Worked great...until I got to PostGIS. Check out this post for details on dealing with the simultaneous postgres 9.1->9.3, postgis 1.5->2.x upgrade: http://sorokine.blogspot.com/2013/11/upgrading-postgresql-91postgis-15-to.html

Thanks!

Worked great...until I got to PostGIS. Check out this post for details on dealing with the simultaneous postgres 9.1->9.3, postgis 1.5->2.x upgrade: http://sorokine.blogspot.com/2013/11/upgrading-postgresql-91postgis-15-to.html

@railsfactory-kumaresan

This comment has been minimized.

Show comment Hide comment
@railsfactory-kumaresan

railsfactory-kumaresan Aug 22, 2014

Thanks @ibussieres. It worked... Awesome

Thanks @ibussieres. It worked... Awesome

@dideler

This comment has been minimized.

Show comment Hide comment
@dideler

dideler Nov 2, 2014

Instructions for upgrading from 9.3 to 9.4: https://gist.github.com/dideler/60c9ce184198666e5ab4

dideler commented Nov 2, 2014

Instructions for upgrading from 9.3 to 9.4: https://gist.github.com/dideler/60c9ce184198666e5ab4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment