Fix pgAdmin Backup & Restore – Incomplete or Corrupt Dumps
In this tutorial, you'll learn about Fix pgAdmin Backup & Restore. We cover key concepts, practical examples, and best practices.
You use pgAdmin's Backup… dialog on a production database, then try to restore it on staging — only to find missing tables, failed constraints, or a dump file that's suspiciously small.
Wrong ❌
# What pgAdmin generates when you click Backup with defaults
pg_dump --host localhost --port 5432 --username postgres --format custom \
--file "/tmp/prod.backup" mydb
On restore:
pg_restore --host localhost --port 5432 --username postgres --dbname staging_mydb \
/tmp/prod.backup
Result:
pg_restore: error: could not execute query: ERROR: relation "users" does not exist
The dump was taken without --schema or --section, but the real issue: the backup didn't include all objects because pgAdmin's defaults skip e.g. --blobs, --no-owner, or --no-tablespaces.
Right ✅
In pgAdmin Backup dialog:
- Right‑click the database → Backup…
- Format: Custom
- Compression:
9(maximum) - Encoding:
UTF8 - Objects: Tick Only data or Only schema as needed, or leave both unticked for full dump
- Options tab:
- ☑ Include CREATE DATABASE statement (for a full restore)
- ☑ Include blobs in dump
- ☑ Use Column Inserts (safer cross‑version)
- Verbose messages (helps debug failures)
- Click Backup
Restore with care:
- Create empty target database:
CREATE DATABASE staging_mydb; - Right‑click it → Restore…
- Pick the backup file
- Options tab:
- ☑ Clean before restore
- ☑ Create objects if they don't exist
- ☐ Exit on error (uncheck to see all warnings)
- Click Restore
pg_restore: processing data for table "users"
pg_restore: processing data for table "orders"
pg_restore: processing data for table "products"
... done
Root Cause
pgAdmin's backup/restore dialogs are wrappers around pg_dump / pg_restore. Defaults vary by pgAdmin version. Missed flags (blobs, ownership, section) cause silent omissions.
Prevention
- Always tick Verbose messages and review the output tab.
- Use Plain format for the first backup — it's human‑readable and easier to debug.
- Restore into a test database first, then run
SELECT count(*)on key tables. - Schedule backups via
cronusing explicitpg_dumpcommands — don't rely on the GUI for automation.
Common Mistakes with backup restore
- Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists - Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
These mistakes appear frequently in real-world PGADMIN code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Design a disaster‑recovery strategy with the [DodaTech PostgreSQL Backup & Recovery course](https://dodatech.com/courses/postgresql-backup).
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro