Azure PostgreSQL Flexible Server Backups Incompatible with pg_restore Directory Format

Jeeva 21 Reputation points
2025-04-08T15:41:47.1866667+00:00

Issue Description

When attempting to restore Azure PostgreSQL Flexible Server backups using the pg_restore directory format (-Fd), the operation fails with the error pg_restore: error: could not open input file "./path/to/pgdump_format/toc.dat": No such file or directory. This occurs because the backup files generated by Azure Backup Vault for PostgreSQL Flexible Server are not created in the proper PostgreSQL directory format expected by pg_restore.

Technical Details

  • Issue: Azure PostgreSQL Flexible Server backup files lack the critical toc.dat file required for directory format restores
  • Environment: Azure Database for PostgreSQL Flexible Server using Azure Backup Vault
  • Command Used: pg_restore -h $SERVER -U $USER -d $DB -Fd -C --no-owner --no-privileges $PGDUMP_DIR
  • Error: pg_restore: error: could not open input file "./path/to/pgdump_format/toc.dat": No such file or directory

Investigation Findings

  1. Azure Backup Vault for PostgreSQL Flexible Server creates individual SQL dump files for each database, not a proper PostgreSQL directory format backup
  2. Files generated are plain SQL dumps, not the binary format with metadata that would be created by pg_dump -Fd
  3. The Azure documentation suggests directory format should work, but the actual files don't support this approach

Workaround

Currently working around the issue by using individual SQL file restores for each database, but this is less efficient than a properly formatted directory restore would be.

Request

  1. Update Azure PostgreSQL Flexible Server backup to properly support directory format backups compatible with pg_restore -Fd
  2. Or, update documentation to clearly indicate this limitation and provide the correct restore approach

Impact

This issue affects automation scripts for disaster recovery scenarios where standard PostgreSQL restore tools are expected to work with Azure-generated backups.

Hub Issue Summary: Azure PostgreSQL Flexible Server Backups Incompatible with pg_restore Directory Format

Doc Reference: https://learn.microsoft.com/en-us/azure/backup/backup-azure-database-postgresql-flex-restore-cli

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,439 questions
{count} votes

Your answer

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