Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to restore the PostgreSQL database from a dump. The below command works fine for me:

CALL "%PGBIN%\pg_restore" -c -d NetCatalog %DUMPFILE%

How can I add a few lines to my .bat file to rename the existing NetCatalog to NetCatalog_Old and create a new database NetCatalog before calling the above line?

PS. Is there an argument that allows me to log the restoring process?


share|improve this question

migrated from Feb 17 '12 at 19:52

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

Something like:

psql -U postgres -d postgres -c "DROP DATABASE netcatalog_old"
psql -U postgres -d postgres -c "ALTER DATABASE netcatalog RENAME TO netcatalog_old"

You can redirect the info output of the restore like

pg_restore ... > my_log_file.txt

If you add the "-v" flag you can get more details of what's happening, but probably too much.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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