I have a dump file (size around 5 GB) which is taken via this command:
pg_dump -U postgres -p 5440 MYPRODDB > MYPRODDB_2022.dmp
The database consists multiple schemas (let’s say Schema A,B,C and D) but i need to restore only one schema (schema A).
How can i achieve that? The command below didn’t work and gave error:
pg_restore -U postgres -d MYPRODDB -n A -p 5440 < MYPRODDB_2022.dmp
pgrestore: error: input file appears to be a text format dump. please
use psql.
2
Answers
You cannot do that with a plain format dump. That’s one of the reasons why you always use a different format unless you need an SQL script.
If you want to stick with a plain text dump:
Though dumping back over the same database as above will throw errors unless you use
--clean
or its short form-c
to create commands to drop existing objects before restoring them:Probably also a good idea to throw in
--if-exists
: