0

I have multiple dump files and want to restore them with single command. something like this

pg_restore  -h localhost -p 5432 -U postgres 
    -d gl_election gl_world gl_tourism 
    -c "gl_election" "gl_world" "gl_tourism"

This command doesn't work and I can't find how to do it correctly. It works fine for one file.

  • Why are you providing 3 arguments to the -d flag, you're trying to load up three databases with pg_restore? – Evan Carroll Dec 5 '17 at 1:49
0

pg_restore doesn't take multiple filenames, nor multiple databases (-d) end of story. So use a simple shell loop. I assume you're trying to

  1. Clear out the old database
  2. Load up a dump to the database with the same name

That loop will look like this

for dump in gl_election gl_world gl_tourism; do
  echo Clearing and reloading "$dump"
  pg_restore -h localhost -p 5432 -U postgres -d "$dump" -c "$dump"
done;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.