简体   繁体   中英

How to restore PostgreSQL database

I'm working in project with a CMS called tendenci using PostgreSQL (it is required) in Ubuntu, and I had to migrate from a Virtual Machine to the production server. But I faced a problems with migrating the database.

I used this command to extract data from VM:

pg_dump -Fc mydb > db.dump

but when I tried to import data to my server with this command

psql -d mydb --file=db.dump 

this error shows up

The input is a PostgreSQL custom-format dump.
Use the pg_restore command-line client to restore this dump to a database.

and when I use pg_restore command no errors show up, but the database doesn't get restored.

pg_restore -C -d mydb db.dump

To move the complete database cluster, including all users etc., use the following commands:

$ pg_dumpall >all-db.sql

and then on the target server initialize an new and emppty database cluster, start it, and then run

$ psql -f all-db.sql

Run the pg_dumpall and psql commands as the postgres user.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM