Backup Vault Corruption - PostgreSQL Flexible Server

Chris J 25 Reputation points
2025-10-29T14:57:24.3933333+00:00

I'm having problems with the long term retention option of PostgreSQL Flexible Server.

When I configure a backup vault everything is fine and I'm able to create a backup on schedule or on-demand.

However, when I restore the data to a storage account the restored data is mostly corrupt. The restore consists of text files (SQL scripts), one for each database.

I say mostly, because some of the files e.g. the roles and schemas seem ok. But the database SQL scripts are unreadable.

I've tried deleting the vault and recreating, but I get the same issue. If I run pg_dump against the server, all the databases dump to file as expected.

Also very easy to reproduce, just create a PostgreSQL Flexible Server and configure Azure Backup Vault. Restore the default databases and they're all corrupt.

Seems to be a fault with the Azure Backup process, anyone else had this problem?

Azure Database for PostgreSQL
{count} votes

Answer accepted by question author
  1. Manoj Kumar Boyini 1,330 Reputation points Microsoft External Staff Moderator
    2025-11-05T19:45:41.9533333+00:00

    Hi Chris J,

    Thank you for reaching out to Microsoft QA. We understand the restored files from the Backup Vault look corrupted.

    In most cases, these files are not damaged but saved in a compressed or custom PostgreSQL format. That is why smaller files like schema or roles look fine, but large database files appear unreadable in editors.

    Please try these steps:

    1. Download one of the affected files using Azure CLI or Storage Explorer (avoid browser download).
    2. Run this command to check the file type: file <filename>
    3. If it shows gzip compressed, run: gunzip -c <filename> > restored.sql If it shows PostgreSQL custom dump, run: pg_restore -Fc <filename> -d <target_database>

    If the file still looks unreadable, please share these details in private message
    Backup Vault name and region, Restore Job ID and time (UTC), One affected file name, how the file was downloaded

    We will check the backend logs to confirm whether this is related to compression or encoding during restore.

    Kindly let us know if you have any questions or concerns.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Chris J 25 Reputation points
    2025-11-06T10:09:06.6766667+00:00

    After running the file <filename> command I realised the format of the database sql scripts was indeed PostgreSQL custom database dump - v1.15-0 so not corrupt at all.

    Thanks for your help, I was able to successfully test the restore process which worked.

    I think the documentation should state this, because I like many will assume the sql script should be text and its not.

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.