Skip to content

Commit 0a6eb45

Browse files
committed
docs: pg_restore error
1 parent cd66406 commit 0a6eb45

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

content/reference/postgres/error/_layout.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
## [42501: permission denied for table](/reference/postgres/error/42501-permission-denied-for-table-postgres)
1414

1515
## [pg_dump: error: aborting because of server version mismatch](/reference/postgres/error/pgdump-aborting-because-of-server-version-mismatch)
16+
17+
## [pg_restore: error: input file appears to be a text format dump. please use psql](/reference/postgres/error/pgrestore-input-file-appears-to-be-a-text-format-dump)
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
title: 'How to fix pg_restore "input file appears to be a text format dump. please use psql"'
3+
---
4+
5+
This error occurs because you're trying to use `pg_restore` on a plain text SQL dump file, but `pg_restore` only works with binary or directory format dumps.
6+
7+
### Option 1: Use psql instead
8+
9+
```bash
10+
psql -U username -d database_name -f dump_file.sql
11+
```
12+
13+
### Option 2: Check if your dump is compressed
14+
15+
If your file has a .gz extension:
16+
17+
```bash
18+
gunzip -c dump_file.sql.gz | psql -U username -d database_name
19+
```
20+
21+
### Option 3: Create a custom/binary format dump
22+
23+
When creating dumps in the future, use the `-Fc` flag with pg_dump:
24+
25+
```bash
26+
pg_dump -Fc -d source_database > backup.dump
27+
```
28+
29+
Then you can use pg_restore with this file:
30+
31+
```bash
32+
pg_restore -d target_database backup.dump
33+
```

0 commit comments

Comments
 (0)