Install PostgreSQL 9.4 echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - sudo apt-get update sudo apt-get upgrade sudo apt-get install postgresql-9.4 postgresql-contrib-9.4 Ensuring permission on pg_hba.conf local all postgres peer Shutdown service sudo service postgresql stop Execute pg_upgrade sudo su postgres /usr/lib/postgresql/9.4/bin/pg_upgrade -b /usr/lib/postgresql/9.1/bin/ \ -B /usr/lib/postgresql/9.4/bin/ \ -d /var/lib/postgresql/9.1/main \ -D /var/lib/postgresql/9.4/main \ -o ' -c config_file=/etc/postgresql/9.1/main/postgresql.conf' \ -O ' -c config_file=/etc/postgresql/9.4/main/postgresql.conf' Start service sudo service postgresql start 9.4 Clean up sudo apt-get remove postgresql-9.1 rm -rf /usr/lib/postgresql/9.1
"pg_upgradecluster -m upgrade 9.1 main" is easier.