pg_basebackup(物理备份)
常用参数速查
参数 | 简写 | 说明 | 示例 |
|
| 备份目标目录(必需) |
|
|
| 输出格式:plain|tar |
或 |
|
| WAL 处理方式 |
流复制 |
| 检查点模式 |
| |
|
| 显示进度 |
|
|
| 详细输出 |
|
|
| 并行压缩/传输 |
|
|
| 压缩方法 |
|
|
| 主机地址 |
|
|
| 端口 |
|
|
| 用户名 |
|
|
| 不提示密码 |
|
|
| 强制提示密码 |
|
pg_basebackup takes a base backup of a running PostgreSQL server. Usage: pg_basebackup [OPTION]... Options controlling the output: -D, --pgdata=DIRECTORY receive base backup into directory -F, --format=p|t output format (plain (default), tar) -r, --max-rate=RATE maximum transfer rate to transfer data directory (in kB/s, or use suffix "k" or "M") -R, --write-recovery-conf write configuration for replication -t, --target=TARGET[:DETAIL] backup target (if other than client) -T, --tablespace-mapping=OLDDIR=NEWDIR relocate tablespace in OLDDIR to NEWDIR --waldir=WALDIR location for the write-ahead log directory -X, --wal-method=none|fetch|stream include required WAL files with specified method -z, --gzip compress tar output -Z, --compress=[{client|server}-]METHOD[:DETAIL] compress on client or server as specified -Z, --compress=none do not compress tar output General options: -c, --checkpoint=fast|spread set fast or spread checkpointing -C, --create-slot create replication slot -l, --label=LABEL set backup label -n, --no-clean do not clean up after errors -N, --no-sync do not wait for changes to be written safely to disk -P, --progress show progress information -S, --slot=SLOTNAME replication slot to use -v, --verbose output verbose messages -V, --version output version information, then exit --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE use algorithm for manifest checksums --manifest-force-encode hex encode all file names in manifest --no-estimate-size do not estimate backup size in server side --no-manifest suppress generation of backup manifest --no-slot prevent creation of temporary replication slot --no-verify-checksums do not verify checksums -?, --help show this help, then exit Connection options: -d, --dbname=CONNSTR connection string -h, --host=HOSTNAME database server host or socket directory -p, --port=PORT database server port number -s, --status-interval=INTERVAL time between status packets sent to server (in seconds) -U, --username=NAME connect as specified database user -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) Report bugs to <pgsql-bugs@lists.postgresql.org>. PostgreSQL home page: <https://www.postgresql.org/>示例
常用备份语法
pg_basebackup -D /opt/pg_basebackup/$(date +"%Y%m%d_%H%M%S") -Fp -Xs -P -v -U rep -h 192.168.0.3pg_basebackup -D /opt/pg_basebackup/$(date +"%Y%m%d_%H%M%S") -Ft -Xs -P -v -U rep -h 192.168.0.3backup_manifest
pg_dump
常用参数速查
参数 | 说明 | 示例 |
| 指定数据库 |
|
| 用户名 |
|
| 主机地址 |
|
| 端口 |
|
| 输出文件(替代 >) |
|
| 输出格式 |
|
| 详细输出 |
|
| 强制提示密码 |
|
| 从不提示密码 |
|
pg_dump dumps a database as a text file or to other formats. Usage: pg_dump [OPTION]... [DBNAME] General options: -f, --file=FILENAME output file or directory name/输出文件名或目录名 -F, --format=c|d|t|p output file format (custom, directory, tar, plain text (default)) -j, --jobs=NUM use this many parallel jobs to dump -v, --verbose verbose mode -V, --version output version information, then exit -Z, --compress=METHOD[:DETAIL] compress as specified --lock-wait-timeout=TIMEOUT fail after waiting TIMEOUT for a table lock --no-sync do not wait for changes to be written safely to disk -?, --help show this help, then exit Options controlling the output content: -a, --data-only dump only the data, not the schema -b, --large-objects include large objects in dump --blobs (same as --large-objects, deprecated) -B, --no-large-objects exclude large objects in dump --no-blobs (same as --no-large-objects, deprecated) -c, --clean clean (drop) database objects before recreating -C, --create include commands to create database in dump -e, --extension=PATTERN dump the specified extension(s) only -E, --encoding=ENCODING dump the data in encoding ENCODING -n, --schema=PATTERN dump the specified schema(s) only -N, --exclude-schema=PATTERN do NOT dump the specified schema(s) -O, --no-owner skip restoration of object ownership in plain-text format -s, --schema-only dump only the schema, no data -S, --superuser=NAME superuser user name to use in plain-text format -t, --table=PATTERN dump only the specified table(s) -T, --exclude-table=PATTERN do NOT dump the specified table(s) -x, --no-privileges do not dump privileges (grant/revoke) --binary-upgrade for use by upgrade utilities only --column-inserts dump data as INSERT commands with column names --disable-dollar-quoting disable dollar quoting, use SQL standard quoting --disable-triggers disable triggers during>示例pg_dump -U postgres -d demo1 > $(date +"%Y%m%d_%H%M%S").sql
![]()