news 2026/7/16 5:03:55

pg_basebackup(物理备份)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
pg_basebackup(物理备份)

pg_basebackup(物理备份)

常用参数速查

参数

简写

说明

示例

--pgdata=DIRECTORY

-D

备份目标目录(必需)

-D /backup/base

--format=p|t

-F

输出格式:plain|tar

-Fp

-Ft

--wal-method=METHOD

-X

WAL 处理方式

-Xs

流复制

--checkpoint=fast|spread

检查点模式

--checkpoint=fast

--progress

-P

显示进度

-P

--verbose

-v

详细输出

-v

--jobs=NUM

-j

并行压缩/传输

-j 4

--compress=METHOD

-z

压缩方法

-z 9

--host=HOSTNAME

-h

主机地址

-h 192.168.1.1

--port=PORT

-p

端口

-p 5432

--username=NAME

-U

用户名

-U rep

--no-password

-w

不提示密码

-w

--password

-W

强制提示密码

-W

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.3

pg_basebackup -D /opt/pg_basebackup/$(date +"%Y%m%d_%H%M%S") -Ft -Xs -P -v -U rep -h 192.168.0.3

backup_manifest

pg_dump

常用参数速查

参数

说明

示例

-d, --dbname=DBNAME

指定数据库

-d mydb

-U, --username=NAME

用户名

-U postgres

-h, --host=HOSTNAME

主机地址

-h 127.0.0.1

-p, --port=PORT

端口

-p 5432

-f, --file=FILENAME

输出文件(替代 >)

-f backup.sql

-F, --format=c|d|t|p

输出格式

-Fc

-v, --verbose

详细输出

-v

-W, --password

强制提示密码

-W

-w, --no-password

从不提示密码

-w

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

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/7/16 5:03:11

逆向工程实战:深度解析Wallpaper Engine的RePKG文件格式与解包工具开发

1. 项目概述&#xff1a;从用户到探索者如果你和我一样&#xff0c;是个喜欢折腾桌面美化的人&#xff0c;那么对 Wallpaper Engine 这款软件一定不陌生。它强大的动态壁纸引擎和创意工坊生态&#xff0c;让我们的桌面从静态图片变成了一个可以互动、可以呼吸的活体空间。但不知…

作者头像 李华
网站建设 2026/7/16 5:01:56

Mac新手上路:DBeaver社区版安装与核心配置避坑指南

1. 为什么选择DBeaver社区版 作为Mac用户&#xff0c;当你需要一款数据库管理工具时&#xff0c;DBeaver社区版绝对是个不错的选择。它完全免费开源&#xff0c;支持几乎所有主流数据库&#xff0c;从MySQL、PostgreSQL到Oracle、SQL Server&#xff0c;甚至连Hive这种大数据组…

作者头像 李华
网站建设 2026/7/16 5:01:27

C# RSA非对称加密实战:从原理到跨平台对接与性能优化

1. 项目概述&#xff1a;为什么C#开发者绕不开RSA&#xff1f;如果你用C#做过任何涉及数据安全传输或存储的功能&#xff0c;比如用户密码令牌、支付接口签名、配置文件加密&#xff0c;那你大概率听说过或者用过RSA。这玩意儿就像程序世界的“数字信封”&#xff1a;发信人用一…

作者头像 李华
网站建设 2026/7/16 5:01:07

C++哈希表原理与实战:从O(1)查找优化到unordered_map深度解析

1. 项目概述&#xff1a;为什么哈希表是C进阶的必经之路&#xff1f;如果你已经写过一些C程序&#xff0c;用过std::vector和std::map&#xff0c;并且开始对“性能”这个词变得敏感&#xff0c;那么哈希表&#xff08;Hash Table&#xff09;就是你绕不开的一道坎。它不是那种…

作者头像 李华
网站建设 2026/7/16 4:59:49

宋度宗赵禥:孱弱误国的南宋末代衰世帝王

一、人物介绍 赵禥&#xff08;1240年&#xff0d;1274年&#xff09;&#xff0c;南宋第六位皇帝&#xff0c;史称宋度宗。他是宋理宗之侄&#xff0c;因理宗子嗣早夭被立为储君。赵禥天资孱弱、资质平庸&#xff0c;自幼体弱多病&#xff0c;登基时南宋早已积重难返、风雨飘…

作者头像 李华