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?
Use “-d” comamnd line option to provide database name to pg_dump command. Make sure to replace your actual database name in place of mydb . Restore a single database from backup in PostgreSQL. Just use “psql” command to restore PostgreSQL database.
You can't restore it to a PostgreSQL database. If you need to migrate the data from SQL Server to Postgres you need to script the data out or use a Migration/ETL tool.
Go to command prompt and directory postgresql\9.3\bin. .. c:\Program files\postgresql\9.3\bin> pg_dump -h localhost -p 5432 -U postgres test > D:\backup.
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 :)
psql -f filenamed.dmp db_name
works fine
For Postrgres 9.2
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [user] -d [db] [filename].dump
Have a look at the pg_restore command.
I found it tricky in windows environment.
pg_restore will not work if its a text format dump. In that case, we need to use psql.
psql -U username -f database.dump databasename
It will prompt for the password of the username and then the restoring process will be initiated.
pg_restore is far from obvious, this is the command I used to create a new database and restore the dumpfile into it on a remote Postgres instance running on AWS. If your connection is correct, pg_restore should immediately ask you to input your password)
pg_restore -h mypostgresdb.eu-west-1.rds.amazonaws.com -U adminuser --verbose -C -d existingdatabase mydbdump.dm
Where the switches are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With