Home
%3CLINGO-SUB%20id%3D%22lingo-sub-803343%22%20slang%3D%22en-US%22%3EBackup%20Azure%20Database%20for%20PostgreSQL%20to%20a%20Blob%20Storage%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-803343%22%20slang%3D%22en-US%22%3E%3CP%3EOften%20customers%20want%20to%20backup%20Azure%20Database%20for%20PostgreSQL%20to%20a%20Blob%20storage%20pg_dump%20commnd%20can't%20directly%20write%20the%20output%20file%20on%20a%20Blob%20Storage%2C%20in%20this%20post%20I%20will%20explain%20how%20this%20can%20be%20done%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Ffiles%2Fstorage-files-introduction%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Files%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1-%20Navigate%20to%20your%20Azure%20Database%20for%20PostgreSQL%20server%20on%20the%20portal%20and%20Run%26nbsp%3B%3CA%20style%3D%22background-color%3A%20%23ffffff%3B%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Fquickstart%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzure%20Cloud%20Shell%20(Bash).%26nbsp%3B%3C%2FA%3EIf%20you%20run%20this%20for%20the%20first%20time%20it%20will%20ask%20you%20to%20create%20a%20Storage%20container%20and%20and%20this%20will%20mount%20an%20Azure%20File%20in%20it.%3C%2FP%3E%0A%3CP%3E2-%20Type%20%3CSTRONG%3E%3CEM%3Edf%3C%2FEM%3E%3C%2FSTRONG%3Ein%20the%20cloud%20shell%20and%20collect%20the%20Azure%20File%20path%3C%2FP%3E%0A%3CP%3E3-%20Change%20directory%20to%20the%20cloud%20drive%20using%20the%20%3CSTRONG%3E%3CEM%3Ecd%3C%2FEM%3E%3C%2FSTRONG%3Ecommand%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bin%20the%20example%20below%20I%20used%26nbsp%3B%3CEM%3Ecd%20%2Fusr%2Fbashar%2Fclouddrive%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E4-%20Now%20that%20you%20are%20in%20that%20directory%20run%20the%20pg_dump%20command%20to%20extract%20the%20backup%20dump%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126836i98D0CFF97DA7B38E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22pg_dump.jpg%22%20title%3D%22pg_dump.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E5-%20Backup%20file%20is%20ready%20and%20in%20this%20example%20it%20is%20under%20File%20System%20%22%3CEM%3Ecs47e4f0dddd931x4619xbf7%3C%2FEM%3E%22%2C%20navigate%20on%20the%20Azure%20Portal%20to%20that%20file%20system%2C%20as%20in%20the%20following%20screenshot.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126837iABDF21E1B3E3944F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22file%20system.jpg%22%20title%3D%22file%20system.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E6-%20Download%20backup%20file%20if%20needed%20or%20alternatively%20move%20it%20to%20Blob%20Storage%20using%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fstorage%2Fcommon%2Fstorage-use-azcopy-v10%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%20noopener%20noreferrer%22%3EAzCopy%20%3C%2FA%3Eutility%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F126851iA2071089413AF56C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22backup.jpg%22%20title%3D%22backup.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThanks%20to%20Ramkumar%20Chandrasekaran%20for%20his%20contribution%20in%20this%20post.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-928159%22%20slang%3D%22en-US%22%3ERe%3A%20Backup%20Azure%20Database%20for%20PostgreSQL%20to%20a%20Blob%20Storage%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-928159%22%20slang%3D%22en-US%22%3E%3CP%3EThanks!%20Worked%20perfectly%20-%20apart%20from%20the%2020min%20CloudShell%20timeout...%3C%2FP%3E%3C%2FLINGO-BODY%3E
Microsoft

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

pg_dump.jpg

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.

file system.jpg


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

 

Thanks to Ramkumar Chandrasekaran for his contribution in this post.

1 Comment
Occasional Visitor

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