逻辑备份与还原
pg_dump.exe逻辑备份
- 是客户端工具
- 生成的是标准的sql文件。
- 可以选择 打包、压缩、自定义格式的不同的输出形式
- 数据一致的,因为postgresql数据库是mvc特性的
与pg_dump.exe输出备份之对应的还原
- 何种输出就需要何种逆向操作,最终就是要获得标准的sql输入
pg_dump.exe的选项 pg_dump [选项]... [数据库名字]
- pg_dump.exe --no-owner --no-privileges --create
- pg_dump.exe --no-owner --no-privileges --create --inserts
一般选项: -f,--file=文件名 输出文件名 -F,--format=c|t|p 输出文件格式 (定制,tar,明文) -i,--ignore-version 当服务器的版本号与 pg_dump 的版本号不匹配时仍继续运行 -v,--verbose 详细模式 -Z,--compress=0-9 被压缩格式的压缩级别 --help 显示此帮助信息,然后退出 --version 输出版本信息,然后退出 控制输出内容选项: -a,--data-only dump only the data,not the schema --仅备份数据。用于还原的数据库和备份的数据库结构完全一致时!
-s,--schema-only dump only the schema,no data --仅备份结构。用于生成结构脚本
-c,--clean clean (drop) schema prior to create --重新生成目标表。和--create是不兼容选项。被还原的库应该存在!! -C,--create include commands to create database in dump --创建数据库,用于创建完全的备份。和--clean是不兼容选项。一般情况下,该选项不起作用!!
-O,--no-owner skip restoration of object ownershipin plain text format -x,--no-privileges do not dump privileges (grant/revoke)
-t,--table=TABLE dump the named table(s) only -T,--exclude-table=TABLE do NOT dump the named table(s)
-n,--schema=SCHEMA dump the named schema(s) only --指定要导出的构架 -N,--exclude-schema=SCHEMA do NOT dump the named schema(s) --指定要排除的构架
-b,--blobs include large objects in dump -d,--inserts dump data as INSERT commands,rather than COPY -D,--column-inserts dump data as INSERT commands with column names -E,--encoding=ENCODING dump the data in encoding ENCODING
-o,--oids include OIDs in dump -S,--superuser=NAME specify the superuser user name to use in plain text format --disable-dollar-quoting disable dollar quoting,use SQL standard quoting --disable-triggers disable triggers during data-only restore --use-set-session-authorization use SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set ownership 联接选项: -h,--host=主机名 数据库服务器的主机名或套接字目录 -p,--port=端口号 数据库服务器的端口号 -U,--username=名字 以指定的数据库用户联接 -W,--password 强制口令提示 (自动) 如果没有提供数据库名字,那么使用 PGDATABASE 环境变量 的数值.
恢复数据库实例amohpj
pg_restore.exe -hlocalhost -Upostgres -damohpj -v "C:amohpj.dat" (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|