Florin Lipan

Welcome to my personal website.

Scroll down for my blog.

I'm a Ruby developer with a strong devops background and leadership experience. I have a personal interest in languages like Crystal and Rust. I like building things.

If you'd like to know more, check out my projects on GitHub, join me on LinkedIn, follow me on Twitter or just write me an email. You can find my CV here.

↞ Back

Upgrading Postgres and migrating your data to the new version

After upgrading your Postgres server to a newer version, your data will not be migrated automatically to the new installation.

In order to do so, you’ll need both versions of Postgres installed on your machine. If you’ve uninstalled the old version, you can install it again by following these instructions.

By default, every Postgres installation creates a main cluster. On Ubuntu, the data of the main cluster is stored under /var/lib/postgresql/VERSION/main.

Your fresh installation already created its own main cluster so you’ll need to drop if before migrating the old data:

sudo pg_dropcluster NEW_VERSION main

Afterwards, you can migrate the old cluster data by calling:

sudo pg_upgradecluster OLD_VERSION main

Check that your new Posgres version contains all your old data:

psql postgres

At this point it’s safe to remove the old cluster and the entire old package:

sudo pg_dropcluster OLD_VERSION main
sudo apt remove postgresql-OLD_VERSION
Share on Hacker News
Share on Reddit