Upgrading PostgreSQL for an instance

This page describes how to move your data to an instance running a later version of PostgreSQL.

Introduction

The steps for moving your data from one version of PostgreSQL to another involve exporting data from the current instance and importing that data into a new instance running the later version of PostgreSQL.

Before you begin

Before moving your data to an instance running a newer version of PostgreSQL, familiarize yourself with the differences between the PostgreSQL versions:

Upgrading

To move your data to a Cloud SQL instance running a later version of PostgreSQL:

  1. Create the target instance, with the desired PostgreSQL version.

    Make sure the target instance has:

    • Sufficient storage to hold all of the current instance's data.
    • The same authorized networks as the current instance. Learn more.

    • The same user accounts, with the same PostgreSQL privileges and passwords.

    For help with creating an instance, see Creating an instance.

  2. Confirm that you can connect to the new instance with your local PostgreSQL tools and update them if necessary.

  3. Export the current instance's data to a PostgreSQL dump file, following the instructions in Exporting data for Import into Cloud SQL.

    Do not export the postgres system database. The postgres database is the default database you connect to before you have created any other databases. Once you create another database, switch to it in order to create tables and insert data. Don't use the postgres database for your application's data.

  4. Create a Cloud Storage bucket if needed, and upload your SQL dump file to the bucket.

  5. Import the data to the target instance, following the instructions in Importing PostgreSQL databases from Cloud Storage.

  6. Update your applications to connect to the new instance.

  7. When you are confident that your new instance is operating successfully, delete the old instance.

What's next