Blog Post

Azure Database for PostgreSQL Blog
1 MIN READ

Backup Azure Database for PostgreSQL to a Blob Storage

Bashar-MSFT's avatar
Bashar-MSFT
Former Employee
Aug 13, 2019

Often customers want to backup Azure Database for PostgreSQL to a Blob storage pg_dump commnd can't directly write the output file on a Blob Storage, in this post I will explain how this can be done using Azure Files.

 

1- Navigate to your Azure Database for PostgreSQL server on the portal and Run Azure Cloud Shell (Bash). If you run this for the first time it will ask you to create a Storage container and and this will mount an Azure File in it.

2- Type df in the cloud shell and collect the Azure File path

3- Change directory to the cloud drive using the cd command
     in the example below I used cd /usr/bashar/clouddrive

4- Now that you are in that directory run the pg_dump command to extract the backup dump

5- Backup file is ready and in this example it is under File System "cs47e4f0dddd931x4619xbf7", navigate on the Azure Portal to that file system, as in the following screenshot.


6- Download backup file if needed or alternatively move it to Blob Storage using AzCopy utility

 

Thanks to Ramkumar Chandrasekaran for his contribution in this post.

Updated Aug 13, 2019
Version 5.0

5 Comments

  • narubby's avatar
    narubby
    Copper Contributor

    Cloud shell is really not the right tool for the job, except for most trivial use cases. Problems are e.g. CPU/Memory performance, idle timeouts, VNet Integration, server version mismatches of the pg_* tools, and you are not able to install other tools on that machine

  • usmankhawar's avatar
    usmankhawar
    Copper Contributor

    How to take backup like this when the PostgresServer is within Virtual network?

    (It doesn't allow connecting via Azure CLI)

  • kousal_Reddy's avatar
    kousal_Reddy
    Copper Contributor

    Adding to that if the CloudShell timeouts will the dump process still be running at the background

  • kousal_Reddy's avatar
    kousal_Reddy
    Copper Contributor

    We have initiated the Dump of the Database size 52GB Its running from past 1hr do we have any to know the completed dump percentage Thanks in advance!!

  • realprodnik's avatar
    realprodnik
    Copper Contributor

    Thanks! Worked perfectly - apart from the 20min CloudShell timeout...