A table\'s rows were mistakenly deleted from the database. We have a db backup which results in a sql file that can restored like so:
psql -h localhost -d pr
I've recently written a step by step guide on how to restore individual postgres tables.
In short it doesn't work with SQL backups, you need to switch to pg_dump
to generate backup files:
pg_dump.exe --host localhost --port 5432 --username "postgres" --schema "public" --format custom --blobs --verbose --file "my_database.dump" "my_database"
Then, whenever you need to restore a specific table for data recovery or bug investigating purposes, you'll have to:
my_database_restored
my_table
in the empty databasepg_restore
to selectively import desired table’s data:pg_restore.exe -U postgres --data-only -d "my_database_restored" -t "my_table" "my_database.dump"