postgres12数据库备份方式五
编写目的
根据(postgres12数据库备份方式四)上一章节配置,讲解如何实现归档还原,在这章讲解如如何备份SQL脚本。
备份SQL脚本与还原
#备份sql脚本,test是数据库名称,根据你的需求改变。
pg_dump -h 192.168.207.170 -p 15432 -U postgres -c -C -f test.sql test
#全部数据库进行备份
pg_dumpall -h 192.168.207.170 -p 15432 -U postgres -c -v -f test.sql
#导入备份到数据库中
psql -h 192.168.207.170 -p 15432 -U postgres -f test.sql