How to fix pg_restore: error: input file appears to be a text format dump in PostgreSQL

PostgreSQLBEGINNERMEDIUMUpdated Dec 28, 2025ยท 236 views

pg_restore only works with binary or directory format dumps, not plain text SQL files. Use psql to restore text dumps or recreate dumps using pg_dump with the -Fc (custom) format flag.

Quick fix

Fixes pg_restore: error: input file appears to be a text format dump

head -1 /path/to/dump.sql
  1. Check your dump file format
  2. Restore using psql (for plain text dumps)
  3. Create dumps in custom format for pg_restore (recommended)
  4. Enable parallel restoration for large dumps
postgresql โ€” error
head -1 /path/to/dump.sql
pg_restore: error: input file appears to be a text format dump

What this error means

This error occurs when you try to use the pg_restore utility on a plain text SQL dump file. The pg_restore tool is designed exclusively for restoring backups created in PostgreSQL's custom (-Fc), directory (-Fd), or tar (-Ft) archive formats. Plain text SQL dumps, which are plain-text files containing SQL commands, must be restored using the psql command-line client instead. The error message indicates a format mismatch between the dump file and the restoration tool being used.

Typical symptoms

  • pg_restore command fails immediately with "input file appears to be a text format dump" error
  • Attempting to restore a .sql file with pg_restore instead of psql
  • Getting the error message "Please use psql" in the output
  • Database restoration fails when using backup tools that use pg_restore on text format dumps

Common causes

  1. Created database dump using default pg_dump format (plain text SQL) without specifying a binary format flag
  2. Using pg_restore on a .sql file instead of using psql
  3. Backup automation tools or scripts that use pg_restore instead of psql for text dumps
  4. Confusion between dump formats: plain text (-Fp, default), custom (-Fc), directory (-Fd), and tar (-Ft)

How to fix "pg_restore: error: input file appears to be a text format dump"

1Check your dump file format

First, verify whether your dump is in plain text format by examining the first line:

bash
head -1 /path/to/dump.sql

If it shows SQL statements like "CREATE TABLE", "INSERT INTO", or PostgreSQL version comments, it is a plain text dump. If it shows binary data or has a specific header, it may be a custom format.

2Restore using psql (for plain text dumps)

If you have a plain text SQL dump, restore it using psql instead of pg_restore:

bash
psql -U username -d database_name < /path/to/dump.sql

Alternatively, use the -f flag:

bash
psql -U username -d database_name -f /path/to/dump.sql

Replace "username" with your PostgreSQL user, "database_name" with the target database, and provide the correct path to your dump file.

3Create dumps in custom format for pg_restore (recommended)

To use pg_restore in the future, create dumps using the custom format with the -Fc flag:

bash
pg_dump -Fc -U username -d source_database > backup.dump

Then restore using pg_restore:

bash
pg_restore -U username -d target_database backup.dump

The custom format provides better compression, faster restoration, and the ability to restore specific tables.

4Enable parallel restoration for large dumps

When using the custom format, you can speed up restoration with parallel jobs using the -j flag:

bash
pg_restore -U username -d target_database -j 4 backup.dump

Replace "4" with the number of parallel jobs (typically matching your CPU core count for best performance).

5Fix backup automation tools

If you are using backup automation (e.g., Laravel Backup, DBeaver, or other tools), update their configuration to:
- Use psql for text format dumps, or
- Configure the backup tool to create dumps in custom format (-Fc) and use pg_restore
Check your backup tool's documentation for the correct configuration option for dump format.

Advanced notes

Plain text dumps are the default output of pg_dump and are portable across different PostgreSQL versions and architectures. However, for production environments, the custom format (-Fc) is recommended because it offers compression by default, supports parallel restoration with -j flag, and allows selective restoration of individual tables without loading the entire dump into memory. The directory format (-Fd) is also useful for very large databases as it creates a directory structure that can be backed up incrementally. When migrating between PostgreSQL versions, custom or directory formats are preferred as they provide better control over the restoration process.

Frequently asked questions

What does "pg_restore: error: input file appears to be a text format dump" mean?
This error occurs when you try to use the pg_restore utility on a plain text SQL dump file. The pg_restore tool is designed exclusively for restoring backups created in PostgreSQL's custom (-Fc), directory (-Fd), or tar (-Ft) archive formats. Plain text SQL dumps, which are plain-text files containing SQL commands, must be restored using the psql command-line client instead.
How do I fix "pg_restore: error: input file appears to be a text format dump"?
pg_restore only works with binary or directory format dumps, not plain text SQL files. Use psql to restore text dumps or recreate dumps using pg_dump with the -Fc (custom) format flag.
What causes "pg_restore: error: input file appears to be a text format dump"?
Created database dump using default pg_dump format (plain text SQL) without specifying a binary format flag Using pg_restore on a .sql file instead of using psql Backup automation tools or scripts that use pg_restore instead of psql for text dumps
Is the "pg_restore: error: input file appears to be a text format dump" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading