使用Postgresql内建格式(custom格式)
/Library/Postgresql/9.6/bin/pg_dump --host localhost --port 5432 --username "postgres" --password --format custom --blobs --encoding UTF8 --no-privileges --verbose --file "/home/my/dbname.backup" --schema "app" --schema "sys" "dbname"
使用sql格式(plain格式)
/Library/Postgresql/9.6/bin/pg_dump --host localhost --port 5432 --username "postgres" --no-password --format plain --no-owner --encoding UTF8 --inserts --column-inserts --no-privileges --verbose --file "/home/my/dbname.sql" --schema "app" --schema "sys" "dbname"
恢复数据库(custom格式)
#覆盖已有的数据, pg_restore --host localhost --port 5432 --username "db_user" --dbname "db_name" --password --no-owner --no-privileges --clean --verbose "/home/my/dbname.backup" #新建数据库 pg_restore --host localhost --port 5432 --username "db_user" --dbname "db_name" --password --no-owner --no-privileges --verbose "/home/my/dbname.backup" #差别在于是否有 --clean
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。