Fix for pg_restore "unsupported file header" Version Error
Fix for pg_restore "unsupported file header" Version Error
Fix for pg_restore "unsupported file header" Version Error
This guide addresses the error: pg_restore: error: input file appears to be a text format dump. Please use psql to restore this dump. pg_restore: error: unsupported version (1.xx) in file header
Problem
This error occurs when your local pg_restore version is older than the version used to create the dump file. The mismatch between versions causes the "unsupported file header" error.
Solution for macOS
Using Homebrew
- Update and install newer libpq:
brew update
brew install libpq
# or if already installed
brew upgrade libpq
- Link libpq (required because it's keg-only):
brew link --force libpq
- Add to your PATH in ~/.zshrc or ~/.bash_profile:
export PATH="/opt/homebrew/opt/libpq/bin:$PATH"
Solution for Ubuntu
Using APT
sudo apt update
sudo apt install libpq-dev
Verify Fix
- Check new version after installation:
pg_restore --version
- Try restoring your dump file again. The error should be resolved if your pg_restore version now matches or exceeds the version used to create the dump.
Notes
- This fixes version mismatch issues by updating pg_restore to a newer version
- If you still get a text format error, your dump might be in plain text format (.sql) rather than custom format (.backup). Use psql instead for text dumps
- Make sure to restart your terminal after updating PATH
Did this answer your question?
😞
😐
🤩
Last updated on December 24, 2024