postgresql- restoring .dump file

shahul picture shahul · Dec 8, 2009 · Viewed 53.4k times · Source

I am new for psql. I got from my server data.dump file. I need to restore it in my local. I tried these commands.

i) psql -U postgres dbname -f servicedb.dump

Error:
      psql: warning: extra command-line argument "-f" ignored
      psql: warning: extra command-line argument "servicedb.dump" ignored

ii) psql -U postgres dbname < servicedb.dump

 Error:
              ^
 ERROR:  syntaxe error at or near "☺"
 LINE 1: ☺☺

What is this ".dump" file and how to restore it?

Answer

marrossa picture marrossa · Nov 18, 2011

I got a .dump file from my server (Heroku). As Klaus said, pg_restore is the only way I could restore it in my local.

What I wrote in my terminal was:

pg_restore -c -d [database_name] [dumpfile_name].dump

There are a lot of options you can see in Klaus link of pg_restore :)