PostgreSQL pg_dump custom file input not dumping data

pg-dumppostgresql

When I'm using custom format (-Fc) in pg_dump, the file is smaller (42kb), and when I restore it, it only restores the tables and columns, not the data.

But when I try to use plain text (-Fp), the file is larger (73kb), and when I try to restore it, all data are included (table, column, rows, etc).

Also, when I try to use a Database Manager (dBeaver to be exact), and I try to backup, I can see the command, and it's the same command that I use in pg_dump. But the dump file is larger (73kb) and when I tried to restore using that dump, all data are included.

Any ideas on what seems to be the problem? As of now, I'm using plain-text as the format, but I want to use the custom one.

I'm using PostgreSQL 11.2.

This is full command that I was using in pg_dump. And this is the exact same command that dBeaver is using to dump the database.

pg_dump.exe --format=c -n public --verbose --host=localhost --port=5432 --username=postgres -f db.backup postgres_db

Best Answer

I usually do this and I do not have that problem.

Backup

pg_dump -p 5432 -U postgres -Fc -d postgres -f /tmp/postgres.custom

Restoration

pg_restore -d postgres -p 5432 -U postgres -C /tmp/postgres.custom