postgres 数据备份和导入

导出整个库
.\pg_dump.exe -h 127.0.0.1 -p 5432 -U postgres -c -C -f db.sql dbname
恢复
.\psql.exe -h 127.0.0.1 -p 5432 -U postgres -f .\dbname.sql

导出单个数据库下的模式
 .\pg_dump.exe -h 127.0.0.1 -p 5432 -U postgres -n schema -d dbname -f schemafile.sql
 .\pg_dump.exe -h 127.0.0.1 -p 6454 -U postgres -n schema -d pg-result -f filename.sql

 .\pg_dump.exe  -h 127.0.0.1 -p 6454 -U postgres -n schema -d dbname -f filename.sql

恢复单个数据库下的模式
 .\psql.exe -h 127.0.0.1 -p 6105 -U postgres -d dbname -f filename.sql

重新加载配置文件
SELECT pg_reload_conf();


最新
导出数据库 backup 文件
pg_dump -U postgres -Fc -f D:\xxx.backup dbname
pg_restore -h 192.9.1.28 -p 5432 -U postgres -W -d dbname -v "C:\Users\Administrator\Desktop\xxx.backup"

 

posted @ 2022-02-12 11:24  qukaige  阅读(208)  评论(0编辑  收藏  举报