返回列表 回复 发帖

postgresql db dump

Dump all global objects, such as users and groups (don't know if they were missing in your dump):

pg_dumpall -g -U postgres > globals.sql

Dump schema of database:

pg_dump -Fp -s -v -f db-schema.sql -U postgres dbname

Dump contents of database:

pg_dump -Fc -v -f full.dump -U postgres dbname

Now restore.

psql -f globals.sql
psql -f schema.sql dbname
pg_restore -a -d dbname -Fc full.dump
create db and give it to user:

CREATE DATABASE dbname OWNER rolename;

more:
http://www.postgresql.org/docs/8.1/static/manage-ag-createdb.html
返回列表