27

I exported a postgres db from pgAdmin in a plain format because I wanted to search the whole db text. I then tried to restore the database back but it gives an error saying that the archive file is not valid archive file. How do I restore the db back if it can be restored?

yankitwizzy
  • 391
  • 1
  • 4
  • 7

1 Answers1

27

run:

psql -U your_user_name your_db_name < your_dump_file
guido
  • 386
  • 3
  • 7
  • I am on windows 7. Can I do this on windows 7? –  Feb 21 '12 at 11:09
  • it should, if psql frontend is included in the postgresql package. Try to fire up a terminal, then cd to postgresql bin directory and try to run psql –  Feb 21 '12 at 11:13
  • I tried it now. It didnt work. There is psql.bat file in the postgres bin directory. I am using postgres 8.3 –  Feb 21 '12 at 11:17
  • what do you mean with 'it didnt work'? if there is psql.bat however, try with that, it should run psql. look here for help http://archives.postgresql.org/pgsql-admin/2006-12/msg00091.php –  Feb 21 '12 at 11:22
  • Sorry I meant there is no psql.bat file in the bin directory –  Feb 21 '12 at 11:27
  • sorry but pgadmin cannot restore plain text dumps afaik; so you have two options if you deleted your db and you only have that backup: 1 you depend on running psql frontend in terminal as above; 2 you open the plain text backup and select all/copy, then paste everything in a pgadmin query window and run –  Feb 21 '12 at 11:38
  • This works, only the first argument after -U needs to be your user name not the data base name. psql -U your_user_name your_db_name < your_dump_file – al gh Oct 05 '13 at 04:19