Online Migration to PostgreSQL Flexible Server on Azure from Single Server
Published Apr 17 2024 02:48 PM 1,728 Views

Introducing support in Public Preview for Online migration from Azure Database for PostgreSQL - Single Server to Azure Database for PostgreSQL - Flexible Server. This online migration capability has been requested by many of you— and will add flexibility to your database migrations. 


How can I use Online migration? 


The Online migration is available in the Azure portal on the Migration setup screen, in the “Migration mode drop down selection box, once you initiate a migration from the Flexible server page.



Figure 1: Screenshot from the Azure Portal from the Migration setup page. Here you can select the “Online” migration mode to migrate from Azure Database for PostgreSQL Single server to Azure Database for PostgreSQL- Flexible server 


It can also be used from the Azure CLI by specifying the 'migration-mode' parameter as 'Online'. 

For more information, refer to the migration tutorials using Azure portal and the Azure CLI. 


How does Online migration work? 


In an online database migration to Azure Database for PostgreSQL – Flexible Server, your application that is connecting to your Postgres Single Server (the source) is not stopped while your database(s) are copied to Flexible Server (the target). Instead, the initial copy of the database(s) is followed by replication to keep the Postgres Flexible Server (the target) in sync with the Postgres Single Server. (the source).


A cutover is performed when the Azure Database for PostgreSQL - Flexible Server is in complete sync with the Postgres Single Server, resulting in minimal downtime.



Figure 2: Cutover in Online migration:  Screenshot from the Migration status screen, where you can execute the cutover and complete the migration. The latency here is zero indicating that target Postgres Flex server is in sync with the source Postgres Single server. 


In the 'TestMigration' above, the Latency is 0 which indicates that the Azure Database for PostgreSQL - Flexible Server is in sync with the Single Server.  


Similarly, Online migration can be executed using the Command Line Interface (CLI) as well. 


Figure 3: Online migration through CLI:  Screenshot when you execute ‘show’ to get the Migration status displays latency for the individual Databases


In the ‘online-CLI-migration’ above, the Latency is 0 for the ‘postgres’ Database being migrated which indicates that the target is in sync with the source. 


Whether you execute the migration from the Portal or the CLI, once the ‘latency’ parameter decreases to 0 or close to 0, you can go ahead and execute the cutover to complete the migration. Before you execute the cutover, it is essential that you: 


  • Stop all writes to the source Single server 
  • Validate the data that has been migrated to the target Flexible server 
  • Copy any custom server parameters and connection security details from the source to the target server 

Once you execute the cutover, the migration shows successful completion. At the point, ensure that you make changes to your application to point all connection strings to the Flexible server. 


What are the differences between Offline and Online migration? 


The following table gives an overview of Offline and Online modes of migration. 


Comparison of Migration modes 



Ideal for small Databases 



Simple to execute, with no manual intervention for cutover 



Migrate without logical replication restrictions 



Ideal for Production databases 



Minimal downtime to Application & better user experience 




Depending on the nature of your workload, you can choose either Offline or Online migration.


Get started with Online migration 


If you’re looking to migrate to Flexible Server from your Single Server database on Azure Database for PostgreSQL, you’ll find the Online migration feature quite useful.  


If you only have a small downtime window in particular and you want to minimize the downtime of moving your production workloads from Azure Database for PostgreSQL – Single Server to Flexible Server, then Online migration could be a good fit for your situation.


Where to find more info about Online migration for Azure Database for PostgreSQL – Flexible Server? 



We’re always eager to hear from you, so please reach out to us at Ask Azure DB for PostgreSQL. 

Version history
Last update:
‎Apr 18 2024 12:02 PM
Updated by: