I have a .backup dump from a single table, but it didn't work restore like a normal backup from an entire db. I'm creating this backup file with the following batch script bin\pg_dump -h localhost -p 5432 -U postgres -F c -b -v -f %BACKUP_FILE% --table <schema.table-name> <db-name>
And i'm restoring it with the pgadmin restore option, i didn't get any error message, the restore run normally, but the table don't show on my db/schema.
-
That you chose to name the file with a ".backup" extension doesn't tell us anything. How did you create it? What command did you use to restore it? What error did you get?– jjanesCommented Oct 15, 2019 at 22:07
-
I edited the question putting the information that was missing on it.– lucazpinheiroCommented Oct 16, 2019 at 16:58
-
I din't named the bakcup file ".backup", it was the extension that file was saved.– lucazpinheiroCommented Oct 16, 2019 at 17:11
-
pgadmin3 or pgadmin4?– jjanesCommented Oct 16, 2019 at 17:30
-
"pg_dump" follows the Linux philosophy, not Windows. It doesn't add suffixes, so .backup must have already been included in '%BACKUP_FILE%', however it got there.– jjanesCommented Oct 16, 2019 at 17:32
2 Answers
I am not sure what you tried so far, please post error message for better understanding,
Try below and post a comment if this works for you or not.
you can use pg_restore to restore a single table :
pg_restore -t my_table -d database_name database.dump
If the dump is not too big, the easiest thing to do is restore the full backup to a temporary database (gzcat backup_file.gz | psql -h host -U user database_name)
dump the one table (pg_dump -t my_table)
, then restore it.
-
I did run the first script, but it ask for a password when the db where i was tryingto restore the table dons't has a password. Commented Oct 16, 2019 at 17:33
The problem was that i was trying to restore a postgis table on a db which did not have the postgis extension. Was just a matter of running the command CREATE EXTENSION postgis;
on the query tool.