This page describes how to migrate your data to an instance running a later
version of PostgreSQL. Before proceeding with this method, consider
upgrading the database major version in-place.
There are two ways to upgrade the database major version of your Cloud SQL
for PostgreSQL instance by migrating your data.
Option 1. Use the Database Migration Service (DMS).
DMS supports migrating from a Cloud SQL for PostgreSQL instance. You can also
use it to upgrade your database version.
Option 2. Move your data from one version of PostgreSQL to another by
exporting data from the current instance and importing that
data into a new instance running the later version of PostgreSQL. This process
involves downtime; you put the current instance into read-only mode before
starting the export.
The rest of this page discusses the second option.
Consider the features offered in each PostgreSQL version and address
incompatibilities.
New major versions introduce incompatible changes that might require you to
modify the application code, the schema, or the database settings before
you can upgrade your database instance. Review the release notes of your
target major version to determine the incompatibilities that you need to
address. If you're skipping major versions, address the incompatibilities
listed for each version that you're skipping.
Perform a dry run of the end-to-end upgrade process with a test instance
before you upgrade the production database. You might want to test the upgrade
using a clone
instead of your production database to avoid any performance impact from the
export on your production workload.
In addition to validating that the upgrade completes successfully, run
tests to understand the expected downtime of the upgrade, confirm your
upgrade workflow, and ensure that the application behaves as expected on the upgraded
database. If you haven't enabled automatic storage increases,
take note of the disk storage used by the upgraded dry run instance to
determine whether you need to increase the storage capacity for the
production instance before upgrading.
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.
Optional. After completing the upgrade process, set up replication
between the source and target instances using pglogical to update the
target with all changes that have occurred since the initial dump was
started. Once the two instances are in sync, you can promote the target
instance.
For information about using pglogical to implement continuous replication,
see Configure your source.
Update your applications to connect to the new instance.
When you're confident that your new instance is operating successfully,
delete the old instance.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[],[],null,["# Upgrade the database major version by migrating data\n\n\u003cbr /\u003e\n\n[MySQL](/sql/docs/mysql/upgrade-major-db-version-migrate \"View this page for the MySQL database engine\") \\| PostgreSQL \\| [SQL Server](/sql/docs/sqlserver/upgrade-major-db-version-migrate \"View this page for the SQL Server database engine\")\n\n\u003cbr /\u003e\n\nThis page describes how to migrate your data to an instance running a later\nversion of PostgreSQL. Before proceeding with this method, consider\n[upgrading the database major version in-place](/sql/docs/postgres/upgrade-major-db-version-inplace).\n\nThere are two ways to upgrade the database major version of your Cloud SQL\nfor PostgreSQL instance by migrating your data.\n\n- **Option 1** . Use the [Database Migration Service (DMS)](/database-migration/docs/postgres/configure-source-database). DMS supports migrating from a Cloud SQL for PostgreSQL instance. You can also use it to upgrade your database version.\n- **Option 2** . Move your data from one version of PostgreSQL to another by *exporting* data from the current instance and *importing* that data into a new instance running the later version of PostgreSQL. This process involves downtime; you put the current instance into read-only mode before starting the export.\n\nThe rest of this page discusses the second option.\n\nPlan a major version upgrade\n----------------------------\n\n1. Choose a target major version.\n\n See the [list of versions that Cloud SQL supports](/sql/docs/postgres/db-versions).\n2. Consider the features offered in each PostgreSQL version and address\n incompatibilities.\n\n New major versions introduce incompatible changes that might require you to\n modify the application code, the schema, or the database settings before\n you can upgrade your database instance. Review the release notes of your\n target major version to determine the incompatibilities that you need to\n address. If you're skipping major versions, address the incompatibilities\n listed for each version that you're skipping.\n - [PostgreSQL 17](https://www.postgresql.org/docs/17/release-17.html)\n - [PostgreSQL 16](https://www.postgresql.org/docs/16/release-16.html)\n - [PostgreSQL 15](https://www.postgresql.org/docs/15/release-15.html)\n - [PostgreSQL 14](https://www.postgresql.org/docs/14/static/release-14.html)\n - [PostgreSQL 13](https://www.postgresql.org/docs/13/static/release-13.html)\n - [PostgreSQL 12](https://www.postgresql.org/docs/12/static/release-12.html)\n - [PostgreSQL 11](https://www.postgresql.org/docs/11/static/release-11.html)\n - [PostgreSQL 10](https://www.postgresql.org/docs/10/static/release-10.html)\n3. Test the upgrade with a dry run.\n\n Perform a dry run of the end-to-end upgrade process with a test instance\n before you upgrade the production database. You might want to test the upgrade\n using a [clone](/sql/docs/postgres/clone-instance)\n instead of your production database to avoid any performance impact from the\n export on your production workload.\n\n In addition to validating that the upgrade completes successfully, run\n tests to understand the expected downtime of the upgrade, confirm your\n upgrade workflow, and ensure that the application behaves as expected on the upgraded\n database. If you haven't enabled [automatic storage increases](/sql/docs/postgres/instance-settings#automatic-storage-increase-2ndgen),\n take note of the disk storage used by the upgraded dry run instance to\n determine whether you need to increase the storage capacity for the\n production instance before upgrading.\n4. Decide when you want to upgrade.\n\n | **Note:** Upgrades require the instance to become unavailable for a period of time. Be sure to schedule your upgrade when database activity is low.\n\nMigrate your data\n-----------------\n\nMigrating entails using the [`pg_dump`](https://www.postgresql.org/docs/14/static/app-pgdump.html)\ncommand to [export the data](/sql/docs/postgres/import-export/import-export-dmp#export)\nfrom the source instance and the [`pg_restore`](https://www.postgresql.org/docs/14/static/app-pgrestore.html)\ncommand to [import the data](/sql/docs/postgres/import-export/import-export-dmp#import)\ninto the target instance.\n\nTo migrate your data to a Cloud SQL instance running a more recent database\nversion, follow these steps:\n\n1. Create the target instance with the desired PostgreSQL version.\n\n Make sure the target instance has:\n - Sufficient storage to hold all of the current instance's data.\n - The same authorized networks as the current instance. [Learn more](/sql/docs/postgres/configure-ip).\n - The same user accounts, with the same PostgreSQL privileges and passwords.\n\n For more information, see [Creating an instance](/sql/docs/postgres/create-instance).\n2. Confirm that you can [connect to the new instance](/sql/docs/postgres/connect-admin-ip) with your local PostgreSQL\n tools and update them, if necessary.\n\n3. Export the current instance's data to a PostgreSQL dump file, following the\n instructions in\n [Exporting data for Import into Cloud SQL](/sql/docs/postgres/import-export/import-export-dmp#external-server).\n\n Do *not* export the `postgres` system database. The `postgres` database is\n the default database you connect to before you have created any other\n databases. Once you create another database, switch to it in order\n to create tables and insert data. Don't use the `postgres` database for your\n application's data.\n4. [Create a Cloud Storage bucket](/storage/docs/creating-buckets)\n if needed, and upload your SQL dump file to the bucket.\n\n5. Import the data to the target instance, following the instructions in\n [Importing PostgreSQL databases from Cloud Storage](/sql/docs/postgres/import-export/import-export-dmp#import_data_using_pg_restore_).\n\n6. Optional. After completing the upgrade process, set up replication\n between the source and target instances using `pglogical` to update the\n target with all changes that have occurred since the initial dump was\n started. Once the two instances are in sync, you can promote the target\n instance.\n\n For information about using `pglogical` to implement continuous replication,\n see [Configure your source](/database-migration/docs/postgres/configure-source-database).\n7. Update your applications to connect to the new instance.\n\n8. When you're confident that your new instance is operating successfully,\n delete the old instance.\n\nWhat's next\n-----------\n\n- Learn about [importing and exporting data](/sql/docs/postgres/import-export).\n- Learn about [options for connecting to an instance](/sql/docs/postgres/external-connection-methods).\n- Learn more about [setting PostgreSQL flags](/sql/docs/postgres/flags)."]]