教学文章
Technology Exchange
400电话

免费咨询热线
400-090-9964

教学文章

PolarDB for PostgreSQL 的备份工具 polar_basebackup

时间:2023-08-24 来源:

PolarDB for PostgreSQL 的备份工具 polar_basebackup,由 PostgreSQL 的 pg_basebackup 改造而来,完全兼容 pg_basebackup,因此同样可以用于对 PostgreSQL 做备份恢复。polar_basebackup 的可执行文件位于 PolarDB for PostgreSQL 安装目录下的 bin/ 目录中。

该工具的主要功能是将一个运行中的 PolarDB for PostgreSQL 数据库的数据目录(包括本地数据目录和共享数据目录)备份到目标目录中。

polar_basebackup takes a base backup of a running PostgreSQL server.

Usage:

polar_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 recovery.conf for replication

-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=0-9 compress tar output with given compression level

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

--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)

--polardata=datadir receive polar data backup into directory

--polar_disk_home=disk_home polar_disk_home for polar data backup

--polar_host_id=host_id polar_host_id for polar data backup

--polar_storage_cluster_name=cluster_name polar_storage_cluster_name for polar data backup

polar_basebackup 的参数及用法几乎和 pg_basebackup 一致,新增了以下与共享存储相关的参数:

--polar_disk_home / --polar_host_id / --polar_storage_cluster_name:这三个参数指定了用于存放备份共享数据的共享存储节点

--polardata:该参数指定了备份共享存储节点上存放共享数据的路径;如不指定,则默认将共享数据备份到本地数据备份目录的 polar_shared_data/ 路径下