IT评测·应用市场-qidao123.com

标题: pgBackRest利用指南 [打印本页]

作者: 写过一篇    时间: 2025-1-5 16:53
标题: pgBackRest利用指南
pgBackRest的简单利用

1. 安装

表1 软硬件要求
软件版本pgbackrest2.52操纵体系处理器架构CentOSx86_64 ​ 从源代码构建时,最好利用构建主机,而不是在生产环境中构建。天生所需的很多工具通常不应安装在生产环境中。pgBackRest 由一个可执行文件组成,因此一旦构建就很容易复制到新主机。
build 将pgBackRest 的 2.52 版本下载到 /build 路径
  1. [root@localhost]# mkdir -p /build
  2. [root@localhost]# cd /build
  3. [root@localhost build]# wget https://github.com/pgbackrest/pgbackrest/archive/refs/tags/release/2.52.tar.gz
  4. [root@localhost build]#tar -zxvf  2.52.tar.gz -C /build
复制代码
build 安装 build 依靠项
  1. sudo yum install make gcc  openssl-devel libxml2-devel lz4-devel libzstd-devel bzip2-devel libyaml-devel libssh2-devel postgresql-devel
复制代码
build设置和编译 pgBackRest
  1. [root@localhost build]#cd /build/pgbackrest-release-2.52/src && ./configure  && make -j8
  2. [root@localhost src]# make install -j8
复制代码
安装完成之后检查。
  1. [fbase@localhost backup]$ pgbackrest
  2. pgBackRest 2.52 - General help
  3. Usage:
  4.     pgbackrest [options] [command]
  5. Commands:
  6.     annotate        Add or modify backup annotation.
  7.     archive-get     Get a WAL segment from the archive.
  8.     archive-push    Push a WAL segment to the archive.
  9.     backup          Backup a database cluster.
  10.     check           Check the configuration.
  11.     expire          Expire backups that exceed retention.
  12.     help            Get help.
  13.     info            Retrieve information about backups.
  14.     repo-get        Get a file from a repository.
  15.     repo-ls         List files in a repository.
  16.     restore         Restore a database cluster.
  17.     server          pgBackRest server.
  18.     server-ping     Ping pgBackRest server.
  19.     stanza-create   Create the required stanza data.
  20.     stanza-delete   Delete a stanza.
  21.     stanza-upgrade  Upgrade a stanza.
  22.     start           Allow pgBackRest processes to run.
  23.     stop            Stop pgBackRest processes from running.
  24.     verify          Verify contents of the repository.
  25.     version         Get version.
  26. Use 'pgbackrest help [command]' for more information.
复制代码
2. 设置

在安装完毕后,后面就是设置相关的pgbackrest必要的设置信息,这里必要进行设置一个供pgbackrest放置设置文件和日志的目录,这里在磁盘目录上建立一个目录 pgbackrest 而且必要postgres 账号在此目录有绝对权限。
这里必要注意,严格按照设置文档中的信息填写,基于编译后,默认文件夹和设置文件读取的位置暂时不能变化。
  1. # 创建日志文件夹
  2. sudo mkdir -p -m 770 /var/log/pgbackrest
  3. # 给fbase用户权限
  4. sudo chown fbase:fbase /var/log/pgbackrest
  5. # 创建
  6. sudo mkdir -p /etc/pgbackrest
  7. # 创建
  8. sudo mkdir -p /etc/pgbackrest/conf.d
  9. # 创建配置文件
  10. sudo touch /etc/pgbackrest/pgbackrest.conf
  11. # 修改配置文件权限
  12. sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
  13. # 给fbase用户配置文件权限
  14. sudo chown fbase:fbase /etc/pgbackrest/pgbackrest.conf
复制代码
然后针对pgbackrest 的设置文件进行简单的设置
  1. [test]
  2. pg1-path=/data/fbase/fbdata
  3. pg1-port=8432
  4. pg1-socket-path=/home/fbase
  5. [global]
  6. repo1-path=/pgbackrest/backup
  7. repo1-retention-full=2
  8. log-level-console=info
  9. log-level-file=debug
  10. [global:archive-push]
  11. compress-level=3
复制代码
修改PostgreSQL数据库的postgresql.conf文件。
  1. archive_command = 'pgbackrest --stanza=test archive-push %p'
复制代码
3. 检查

利用pgbackrest --stanza=test check进行检查。
注意:
完成这些操纵之后,就可以再次执行pgbackrest --stanza=test check来查看是否可以利用。
  1. [fbase@localhost backup]$ pgbackrest --stanza=test check
  2. 2024-07-31 17:43:31.516 P00   INFO: check command begin 2.52: --exec-id=25902-afd5299b --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --stanza=test
  3. 2024-07-31 17:43:32.135 P00   INFO: check repo1 configuration (primary)
  4. 2024-07-31 17:43:32.352 P00   INFO: check repo1 archive for WAL (primary)
  5. 2024-07-31 17:43:32.659 P00   INFO: WAL segment 000000010000000000000005 successfully archived to '/pgbackrest/backup/archive/test/16-1/0000000100000000/000000010000000000000005-bb69fe3aa1ef407b0682b987a1670edec6c4c310.gz' on repo1
  6. 2024-07-31 17:43:32.660 P00   INFO: check command end: completed successfully (1147ms)
复制代码
4. 本地服务器备份操纵

先针对数据库进行全备,然后在进行增量备份等。
  1. [fbase@localhost backup]$ pgbackrest --stanza=test --type=full backup
  2. 2024-07-31 18:16:06.187 P00   INFO: backup command begin 2.52: --exec-id=27616-913efd45 --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --type=full
  3. 2024-07-31 18:16:07.144 P00   INFO: execute non-exclusive backup start: backup begins after the next regular checkpoint completes
  4. WARN: start-fast is disabled and db-timeout (1800s) is smaller than the PostgreSQL checkpoint_timeout (1800s) - timeout may occur before the backup starts
  5. 2024-07-31 18:16:07.868 P00   INFO: backup start archive = 000000010000000000000007, lsn = 0/7000060
  6. 2024-07-31 18:16:07.868 P00   INFO: check archive for prior segment 000000010000000000000006
  7. 2024-07-31 18:16:17.739 P00   INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
  8. 2024-07-31 18:16:17.944 P00   INFO: backup stop archive = 000000010000000000000007, lsn = 0/7000138
  9. 2024-07-31 18:16:17.949 P00   INFO: check archive for segment(s) 000000010000000000000007:000000010000000000000007
  10. 2024-07-31 18:16:17.977 P00   INFO: new backup label = 20240731-181606F
  11. 2024-07-31 18:16:18.029 P00   INFO: full backup size = 22.7MB, file total = 976
  12. 2024-07-31 18:16:18.029 P00   INFO: backup command end: completed successfully (11845ms)
  13. 2024-07-31 18:16:18.030 P00   INFO: expire command begin 2.52: --exec-id=27616-913efd45 --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
  14. 2024-07-31 18:16:18.037 P00   INFO: expire command end: completed successfully (8ms)
复制代码
可以进行差别备份。
  1. [fbase@localhost backup]$ pgbackrest --stanza=test --type=diff --log-level-console=info backup
  2. 2024-07-31 18:25:47.044 P00   INFO: backup command begin 2.52: --exec-id=28116-2901a500 --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --type=diff
  3. 2024-07-31 18:25:47.834 P00   INFO: last backup label = 20240731-181606F, version = 2.52
  4. 2024-07-31 18:25:47.834 P00   INFO: execute non-exclusive backup start: backup begins after the next regular checkpoint completes
  5. WARN: start-fast is disabled and db-timeout (1800s) is smaller than the PostgreSQL checkpoint_timeout (1800s) - timeout may occur before the backup starts
  6. 2024-07-31 18:25:48.553 P00   INFO: backup start archive = 00000001000000000000000A, lsn = 0/A000028
  7. 2024-07-31 18:25:48.553 P00   INFO: check archive for prior segment 000000010000000000000009
  8. 2024-07-31 18:25:49.838 P00   INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
  9. 2024-07-31 18:25:50.046 P00   INFO: backup stop archive = 00000001000000000000000A, lsn = 0/A000138
  10. 2024-07-31 18:25:50.052 P00   INFO: check archive for segment(s) 00000001000000000000000A:00000001000000000000000A
  11. 2024-07-31 18:25:50.073 P00   INFO: new backup label = 20240731-181606F_20240731-182547D
  12. 2024-07-31 18:25:50.118 P00   INFO: diff backup size = 1.6MB, file total = 981
  13. 2024-07-31 18:25:50.118 P00   INFO: backup command end: completed successfully (3077ms)
  14. 2024-07-31 18:25:50.118 P00   INFO: expire command begin 2.52: --exec-id=28116-2901a500 --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
  15. 2024-07-31 18:25:50.124 P00   INFO: expire command end: completed successfully (6ms)
复制代码
在备份后对数据库进行恢复。
  1. # 停止数据库
  2. pg_ctl -D /data/fbase/fbdata stop
  3. # 对原来的数据库文件进行备份
  4. mkdir -p /tmp/data/fbdata
  5. cd /data/fbase/fbdata
  6. tar czvf /tmp/data/fbdata/fbdata.tar.gz *
  7. # 使用pgbackrest命令
  8. pgbackrest --stanza=test --log-level-console=info restore
复制代码
效果显示。
  1. [fbase@localhost backup]$ pgbackrest --stanza=test --log-level-console=info restore
  2. 2024-07-31 18:39:13.554 P00   INFO: restore command begin 2.52: --exec-id=28853-0e5ddf8c --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --repo1-path=/pgbackrest/backup --stanza=test
  3. 2024-07-31 18:39:13.645 P00   INFO: repo1: restore backup set 20240731-181606F_20240731-182547D, recovery will start at 2024-07-31 18:25:47
  4. ERROR: [040]: unable to restore to path '/data/fbase/fbdata' because it contains files
  5.        HINT: try using --delta if this is what you intended.
  6. 2024-07-31 18:39:13.647 P00   INFO: restore command end: aborted with exception [040]
复制代码
删除原先数据库的数据文件,再利用pgbackup工具恢复。
  1. cd /data/fbase/fbdata/
  2. rm -rf *
  3. pgbackrest --stanza=test --log-level-console=info restore
  4. [fbase@localhost root]$ cd /data/fbase/fbdata/
  5. [fbase@localhost fbdata]$ rm -rf *
  6. [fbase@localhost fbdata]$ ll
  7. total 0
  8. [fbase@localhost fbdata]$ pgbackrest --stanza=test --log-level-console=info restore
  9. 2024-07-31 18:41:31.978 P00   INFO: restore command begin 2.52: --exec-id=29018-c21e87e0 --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --repo1-path=/pgbackrest/backup --stanza=test
  10. 2024-07-31 18:41:32.005 P00   INFO: repo1: restore backup set 20240731-181606F_20240731-182547D, recovery will start at 2024-07-31 18:25:47
  11. 2024-07-31 18:41:36.537 P00   INFO: write updated /data/fbase/fbdata/postgresql.auto.conf
  12. 2024-07-31 18:41:36.553 P00   INFO: restore global/pg_control (performed last to ensure aborted restores cannot be started)
  13. 2024-07-31 18:41:36.555 P00   INFO: restore size = 22.7MB, file total = 981
  14. 2024-07-31 18:41:36.556 P00   INFO: restore command end: completed successfully (4583ms)
  15. [fbase@localhost fbdata]$ ll
  16. total 100
  17. -rw-------. 1 fbase fbase   257 Jul 31 18:25 backup_label
  18. drwx------. 5 fbase fbase    30 Jul 31 18:41 base
  19. -rw-------. 1 fbase fbase    44 Jul 31 17:02 current_logfiles
  20. drwx------. 2 fbase fbase  4096 Jul 31 18:41 global
  21. drwx------. 2 fbase fbase  4096 Jul 31 18:41 log
  22. drwx------. 2 fbase fbase    17 Jul 31 18:41 pg_commit_ts
  23. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_dynshmem
  24. -rw-------. 1 fbase fbase  5847 Jul 31 16:24 pg_hba.conf
  25. -rw-------. 1 fbase fbase  2640 Jul 31 16:24 pg_ident.conf
  26. drwx------. 4 fbase fbase    65 Jul 31 18:41 pg_logical
  27. drwx------. 4 fbase fbase    34 Jul 31 18:41 pg_multixact
  28. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_notify
  29. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_replslot
  30. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_serial
  31. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_snapshots
  32. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_stat
  33. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_stat_tmp
  34. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_subtrans
  35. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_tblspc
  36. drwx------. 2 fbase fbase     6 Jul 31 18:41 pg_twophase
  37. -rw-------. 1 fbase fbase     3 Jul 31 16:24 PG_VERSION
  38. drwx------. 3 fbase fbase    27 Jul 31 18:41 pg_wal
  39. drwx------. 2 fbase fbase    17 Jul 31 18:41 pg_xact
  40. -rw-------. 1 fbase fbase   229 Jul 31 18:41 postgresql.auto.conf
  41. -rw-------. 1 fbase fbase 30600 Jul 31 17:02 postgresql.conf
  42. -rw-------. 1 fbase fbase 29635 Jul 31 16:24 postgresql.conf.backup
  43. -rw-------. 1 fbase fbase     0 Jul 31 18:41 recovery.signal
复制代码
尝试启动数据库。
  1. pg_ctl -D /data/fbase/fbdata start
  2. [fbase@localhost fbdata]$ pg_ctl -D /data/fbase/fbdata start
  3. waiting for server to start....2024-07-31 18:42:47 CST [29083]: [1-1] user=,db= LOG:  00000: redirecting log output to logging collector process
  4. 2024-07-31 18:42:47 CST [29083]: [2-1] user=,db= HINT:  Future log output will appear in directory "log".
  5. 2024-07-31 18:42:47 CST [29083]: [3-1] user=,db= LOCATION:  SysLogger_Start, syslogger.c:715
  6. done
  7. server started
  8. [fbase@localhost fbdata]$ psql
  9. psql (16.3)
  10. Type "help" for help.
  11. postgres=#
复制代码
查看表布局和内容。
  1. postgres=# \l
  2.                                                List of databases
  3.    Name    | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
  4. -----------+-------+----------+-----------------+---------+-------+------------+-----------+-------------------
  5. postgres  | fbase | UTF8     | libc            | C       | C     |            |           |
  6. template0 | fbase | UTF8     | libc            | C       | C     |            |           | =c/fbase         +
  7.            |       |          |                 |         |       |            |           | fbase=CTc/fbase
  8. template1 | fbase | UTF8     | libc            | C       | C     |            |           | =c/fbase         +
  9.            |       |          |                 |         |       |            |           | fbase=CTc/fbase
  10. (3 rows)
  11. postgres=# \d
  12.                  List of relations
  13. Schema |          Name          |   Type   | Owner
  14. --------+------------------------+----------+-------
  15. public | cities                 | table    | fbase
  16. public | cities_id_seq          | sequence | fbase
  17. public | computer_config        | table    | fbase
  18. public | computer_config_id_seq | sequence | fbase
  19. (4 rows)
  20. postgres=# select * from computer_config;
  21. id |         cpu          |           gpu           | power_supply  | case_type  |    ram    |   storage    |      motherboard      |  price  
  22. ----+----------------------+-------------------------+---------------+------------+-----------+--------------+-----------------------+---------
  23.   1 | Intel Core i9-13900K | NVIDIA GeForce RTX 4090 | 750W Gold     | Mid Tower  | 32GB DDR5 | 1TB NVMe SSD | ASUS ROG Maximus Z790 | 3500.00
  24.   2 | AMD Ryzen 7 7800X    | AMD Radeon RX 7900 XT   | 650W Platinum | ATX        | 16GB DDR4 | 500GB SSD    | MSI MAG B550          | 2200.00
  25.   3 | Intel Core i7-13700K | NVIDIA GeForce RTX 4080 | 850W Gold     | Full Tower | 32GB DDR4 | 2TB HDD      | Gigabyte Z690 AORUS   | 2900.00
  26.   4 | AMD Ryzen 5 7600X    | NVIDIA GeForce RTX 4070 | 600W Gold     | Micro ATX  | 16GB DDR5 | 1TB SSD      | ASRock B650           | 1800.00
  27.   5 | Intel Core i5-13600K | Intel Arc A770          | 700W Bronze   | Mini ITX   | 32GB DDR4 | 1TB SSD      | ASUS ROG Strix Z690   | 2100.00
  28. (5 rows)
复制代码
查看pgbackup的日志文件。
  1. [root@localhost test]# cd /var/log/pgbackrest/
  2. [root@localhost pgbackrest]# ll
  3. 总用量 2600
  4. -rw-r-----. 1 fbase fbase 1486139 7月  31 18:25 test-backup.log
  5. -rw-r-----. 1 fbase fbase   21873 7月  31 18:25 test-expire.log
  6. -rw-r-----. 1 fbase fbase  624595 7月  31 18:41 test-restore.log
  7. -rw-r-----. 1 fbase fbase   95947 7月  31 17:43 test-stanza-create.log
复制代码
4.1backup 创建 Stanza

  1. su - fbase
  2. pgbackrest --stanza=test --log-level-console=info stanza-create
复制代码
4.2 backup 检查设置文件

  1. pgbackrest --stanza=test --log-level-console=info check
复制代码
4.3 backup full

  1. pgbackrest --stanza=test --log-level-console=info --start-fast --type=full backup
  2. [fbase@pg1 backup]$ pgbackrest --stanza=test --log-level-console=info --start-fast --type=full backup
  3. 2024-08-01 01:29:33.510 P00   INFO: backup command begin 2.52: --exec-id=50115-16e389e8 --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --start-fast --type=full
  4. 2024-08-01 01:29:34.535 P00   INFO: execute non-exclusive backup start: backup begins after the requested immediate checkpoint completes
  5. 2024-08-01 01:29:35.255 P00   INFO: backup start archive = 00000002000000000000000E, lsn = 0/E000060
  6. 2024-08-01 01:29:35.255 P00   INFO: check archive for prior segment 00000002000000000000000D
  7. 2024-08-01 01:29:42.323 P00   INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
  8. 2024-08-01 01:29:42.526 P00   INFO: backup stop archive = 00000002000000000000000E, lsn = 0/E000138
  9. 2024-08-01 01:29:42.531 P00   INFO: check archive for segment(s) 00000002000000000000000E:00000002000000000000000E
  10. 2024-08-01 01:29:42.555 P00   INFO: new backup label = 20240801-012934F
  11. 2024-08-01 01:29:42.596 P00   INFO: full backup size = 22.8MB, file total = 985
  12. 2024-08-01 01:29:42.596 P00   INFO: backup command end: completed successfully (9089ms)
  13. 2024-08-01 01:29:42.596 P00   INFO: expire command begin 2.52: --exec-id=50115-16e389e8 --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
  14. 2024-08-01 01:29:42.622 P00   INFO: repo1: 16-1 remove archive, start = 000000010000000000000005, stop = 000000010000000000000006
  15. 2024-08-01 01:29:42.622 P00   INFO: expire command end: completed successfully (26ms)
复制代码
4.4 backup diff

  1. pgbackrest --stanza=test --log-level-console=info --start-fast --type=diff backup
  2. [fbase@pg1 backup]$ pgbackrest --stanza=test --log-level-console=info --start-fast --type=diff backup
  3. 2024-08-01 01:30:38.060 P00   INFO: backup command begin 2.52: --exec-id=50173-84a77e2e --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --start-fast --type=diff
  4. 2024-08-01 01:30:38.855 P00   INFO: last backup label = 20240801-012934F, version = 2.52
  5. 2024-08-01 01:30:38.855 P00   INFO: execute non-exclusive backup start: backup begins after the requested immediate checkpoint completes
  6. 2024-08-01 01:30:39.594 P00   INFO: backup start archive = 000000020000000000000010, lsn = 0/10000028
  7. 2024-08-01 01:30:39.594 P00   INFO: check archive for prior segment 00000002000000000000000F
  8. 2024-08-01 01:30:40.583 P00   INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
  9. 2024-08-01 01:30:40.793 P00   INFO: backup stop archive = 000000020000000000000010, lsn = 0/10000138
  10. 2024-08-01 01:30:40.799 P00   INFO: check archive for segment(s) 000000020000000000000010:000000020000000000000010
  11. 2024-08-01 01:30:40.823 P00   INFO: new backup label = 20240801-012934F_20240801-013038D
  12. 2024-08-01 01:30:40.867 P00   INFO: diff backup size = 12KB, file total = 985
  13. 2024-08-01 01:30:40.867 P00   INFO: backup command end: completed successfully (2810ms)
  14. 2024-08-01 01:30:40.867 P00   INFO: expire command begin 2.52: --exec-id=50173-84a77e2e --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
  15. 2024-08-01 01:30:40.877 P00   INFO: repo1: 16-1 no archive to remove
  16. 2024-08-01 01:30:40.877 P00   INFO: expire command end: completed successfully (10ms)
复制代码
4.5 backup incr

  1. pgbackrest --stanza=test --log-level-console=info --start-fast --type=incr backup
  2. [fbase@pg1 backup]$ pgbackrest --stanza=test --log-level-console=info --start-fast --type=incr backup
  3. 2024-08-01 01:32:00.307 P00   INFO: backup command begin 2.52: --exec-id=50264-16df3efa --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --pg1-port=8432 --pg1-socket-path=/home/fbase --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test --start-fast --type=incr
  4. 2024-08-01 01:32:01.121 P00   INFO: last backup label = 20240801-012934F_20240801-013038D, version = 2.52
  5. 2024-08-01 01:32:01.121 P00   INFO: execute non-exclusive backup start: backup begins after the requested immediate checkpoint completes
  6. 2024-08-01 01:32:01.856 P00   INFO: backup start archive = 000000020000000000000012, lsn = 0/12000028
  7. 2024-08-01 01:32:01.856 P00   INFO: check archive for prior segment 000000020000000000000011
  8. 2024-08-01 01:32:02.557 P00   INFO: execute non-exclusive backup stop and wait for all WAL segments to archive
  9. 2024-08-01 01:32:02.764 P00   INFO: backup stop archive = 000000020000000000000012, lsn = 0/12000138
  10. 2024-08-01 01:32:02.772 P00   INFO: check archive for segment(s) 000000020000000000000012:000000020000000000000012
  11. 2024-08-01 01:32:02.799 P00   INFO: new backup label = 20240801-012934F_20240801-013200I
  12. 2024-08-01 01:32:02.848 P00   INFO: incr backup size = 14KB, file total = 985
  13. 2024-08-01 01:32:02.848 P00   INFO: backup command end: completed successfully (2544ms)
  14. 2024-08-01 01:32:02.848 P00   INFO: expire command begin 2.52: --exec-id=50264-16df3efa --log-level-console=info --log-level-file=debug --repo1-path=/pgbackrest/backup --repo1-retention-full=2 --stanza=test
  15. 2024-08-01 01:32:02.855 P00   INFO: repo1: 16-1 no archive to remove
  16. 2024-08-01 01:32:02.855 P00   INFO: expire command end: completed successfully (7ms)
复制代码
4.6 backup restore

  1. pgbackrest --stanza=test --log-level-console=info restore[fbase@localhost backup]$ pgbackrest --stanza=test --log-level-console=info restore
  2. 2024-07-31 18:39:13.554 P00   INFO: restore command begin 2.52: --exec-id=28853-0e5ddf8c --log-level-console=info --log-level-file=debug --pg1-path=/data/fbase/fbdata --repo1-path=/pgbackrest/backup --stanza=test
  3. 2024-07-31 18:39:13.645 P00   INFO: repo1: restore backup set 20240731-181606F_20240731-182547D, recovery will start at 2024-07-31 18:25:47
  4. ERROR: [040]: unable to restore to path '/data/fbase/fbdata' because it contains files
  5.        HINT: try using --delta if this is what you intended.
  6. 2024-07-31 18:39:13.647 P00   INFO: restore command end: aborted with exception [040]
复制代码
4.7 backup info

  1. pgbackrest info
  2. [fbase@pg1 backup]$ pgbackrest info
  3. stanza: test
  4.     status: ok
  5.     cipher: none
  6.     db (current)
  7.         wal archive min/max (16): 000000010000000000000007/000000020000000000000012
  8.         full backup: 20240731-181606F
  9.             timestamp start/stop: 2024-07-31 18:16:06+08 / 2024-07-31 18:16:17+08
  10.             wal start/stop: 000000010000000000000007 / 000000010000000000000007
  11.             database size: 22.7MB, database backup size: 22.7MB
  12.             repo1: backup set size: 3MB, backup size: 3MB
  13.         diff backup: 20240731-181606F_20240731-182547D
  14.             timestamp start/stop: 2024-07-31 18:25:47+08 / 2024-07-31 18:25:49+08
  15.             wal start/stop: 00000001000000000000000A / 00000001000000000000000A
  16.             database size: 22.7MB, database backup size: 1.6MB
  17.             repo1: backup set size: 3MB, backup size: 181.7KB
  18.             backup reference list: 20240731-181606F
  19.         full backup: 20240801-012934F
  20.             timestamp start/stop: 2024-08-01 01:29:34+08 / 2024-08-01 01:29:42+08
  21.             wal start/stop: 00000002000000000000000E / 00000002000000000000000E
  22.             database size: 22.8MB, database backup size: 22.8MB
  23.             repo1: backup set size: 3MB, backup size: 3MB
  24.         diff backup: 20240801-012934F_20240801-013038D
  25.             timestamp start/stop: 2024-08-01 01:30:38+08 / 2024-08-01 01:30:40+08
  26.             wal start/stop: 000000020000000000000010 / 000000020000000000000010
  27.             database size: 22.8MB, database backup size: 12KB
  28.             repo1: backup set size: 3MB, backup size: 1.4KB
  29.             backup reference list: 20240801-012934F
  30.         incr backup: 20240801-012934F_20240801-013200I
  31.             timestamp start/stop: 2024-08-01 01:32:00+08 / 2024-08-01 01:32:02+08
  32.             wal start/stop: 000000020000000000000012 / 000000020000000000000012
  33.             database size: 22.8MB, database backup size: 14KB
  34.             repo1: backup set size: 3MB, backup size: 1.6KB
  35.             backup reference list: 20240801-012934F, 20240801-012934F_20240801-013038D
复制代码
5. 远程服务器备份操纵

5.1 环境预备

环境预备主机地址主机名版本作用CentOS-7192.168.198.153standbypg15.7数据库备服务器CentOS-7192.168.198.152primarypg15.7数据库主服务器CentOS-7192.168.198.158buildfbase16.3pgbackrest复制服务器CentOS-7192.168.198.160repository无pgbackrest备份服务器 5.2 在备份服务器上安装pgbackrest

​ 创建 pgbackrest 用户是为了拥有 pgBackRest 存储库。任何用户都可以拥有存储库,但最好不要利用 postgres(如果存在)以避免肴杂。
repository 创建 pgbackrest 用户
  1. [root@repository ~]#useradd  pgbackrest
复制代码
repository 安装依靠项
  1. [root@repository ~]#yum install -y  libzstd  postgresql-libs libssh2
复制代码
repository 从构建主机复制 pgBackRest 二进制文件
  1. [root@repository ~]#scp build:/build/pgbackrest-release-2.52/src/pgbackrest /usr/bin
  2. [root@repository ~]#chmod 755 /usr/bin/pgbackrest
  3. [root@repository pgbackrest]# cat /etc/hosts
  4. 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
  5. ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
  6. 192.168.198.158 build
  7. 192.168.198.152 primary
  8. 192.168.198.153 standby
  9. 192.168.198.160 repository
复制代码
pgBackRest 必要日志和设置目录以及设置文件。
repository 创建 pgBackRest 设置文件和目录
  1. sudo mkdir -p -m 770 /var/log/pgbackrest
  2. sudo chown -Rf pgbackrest:pgbackrest /var/log/pgbackrest
  3. sudo mkdir -p /etc/pgbackrest
  4. sudo mkdir -p /etc/pgbackrest/conf.d
  5. sudo touch /etc/pgbackrest/pgbackrest.conf
  6. sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
  7. sudo chown pgbackrest:pgbackrest /etc/pgbackrest/pgbackrest.conf
复制代码
repository 创建 pgBackRest 存储库
  1. sudo mkdir -p /var/lib/pgbackrest
  2. sudo chmod 750 /var/lib/pgbackrest
  3. sudo chown -Rf pgbackrest:pgbackrest /var/lib/pgbackrest
复制代码
5.3 在数据库主服务器上安装pgbackrest

根据单机安装文档操纵。
安装步骤与pgBackRest在备份服务器上的安装方式没有区别。唯一的区别是在这种环境下日志目录将由 postgres 用户拥有。
  1. [root@primary ~]#su - postgres
  2. [postgres@primary ~]#yum install -y  libzstd  postgresql-libs libssh2
  3. [postgres@primary ~]#scp build:/build/pgbackrest-release-2.52/src/pgbackrest /usr/bin
  4. [postgres@primary ~]#chmod 755 /usr/bin/pgbackrest
复制代码
pgBackRest 必要日志和设置目录以及设置文件。
  1. sudo mkdir -p -m 770 /var/log/pgbackrest
  2. sudo chown -Rf postgres:postgres /var/log/pgbackrest
  3. sudo mkdir -p /etc/pgbackrest
  4. sudo mkdir -p /etc/pgbackrest/conf.d
  5. sudo touch /etc/pgbackrest/pgbackrest.conf
  6. sudo chmod 640 /etc/pgbackrest/pgbackrest.conf
  7. sudo chown postgres:postgres /etc/pgbackrest/pgbackrest.conf
复制代码
primary 创建 pgBackRest 存储库。(可以不设置)
  1. sudo mkdir -p /var/lib/pgbackrest
  2. sudo chmod 750 /var/lib/pgbackrest
  3. sudo chown -Rf postgres:postgres /var/lib/pgbackrest
复制代码
5.4 数据库设置设置

在安装好postgresql数据库的服务器中设置。
pg_hba.conf设置:
  1. su postgres
  2. cd /home/postgres/data
  3. vi pg_hba.conf
  4. # 加入下面这行
  5. host    all             all             0.0.0.0/0                    trust
复制代码
postgresql.conf设置:
  1. vi postgresql.conf
  2. # 修改下面的配置
  3. archive_command = 'pgbackrest --stanza=demo archive-push %p'
  4. archive_mode = on
  5. listen_addresses = '*'
  6. log_line_prefix = '%m [%p]'
  7. max_wal_senders = 10
  8. wal_level = replica
复制代码
5.5 pgbackrest设置

Postgres 集群应该知道它可以将档案流式传输到的 pgBackRest 存储库。相同的存储库信息还可用于恢复备份或执行时间点恢复。为此,我们必要创建一个 pgBackRest 设置文件,并将一些细节添加到 postgres 服务器上的这个文件中。
primary ⇒ 设置pgBackRest /etc/pgbackrest/pgbackrest.conf。
  1. [demo]
  2. pg1-path=/home/postgres/data
  3. pg1-socket-path=/tmp
  4. [global]
  5. log-level-file=detail
  6. repo1-host=repository
  7. repo1-retention-full=7
复制代码
repository ⇒ 设置pgBackRest /etc/pgbackrest/pgbackrest.conf
  1. [demo]
  2. pg1-host=primary
  3. pg1-path=/home/postgres/data
  4. [global]
  5. repo1-path=/var/lib/pgbackrest
  6. repo1-retention-full=7
  7. start-fast=y
复制代码
5.6 设置SSH

pgBackRest 可以将 TLS 与客户端证书结合利用,以启用主机之间的通信。也可以利用 SSH
如下是利用ssh通信的设置步骤:
primary ⇒ 天生SSH密钥对
  1. su - postgres
  2. [postgres@primary ~]$ ssh-keygen -t rsa -b 4096 -C "pgbackrest"
复制代码
天生的密钥默认存储在~/.ssh/id_rsa和~/.ssh/id_rsa.pub。
primary ⇒ 将公钥复制到备份仓库主机
  1. [postgres@primary ~]$ ssh-copy-id pgbackrest@repository
复制代码
如果默认路径不是~/.ssh/id_rsa.pub,请指定公钥路径。
repository ⇒ 天生SSH密钥对
  1. su - pgbackrest
  2. [pgbackrest@repository  ~]$ ssh-keygen -t rsa -b 4096 -C "pgbackrest"
  3. [pgbackrest@repository  ~]$ ssh-copy-id postgres@primary
复制代码
5.7 在 PostgreSQL 服务器上设置必填参数

以下是要在 postgres 服务器上设置的强制参数,以确保 pgBackRest 成功运行。
**archive_mode :**此参数必须设置为“ON”以确保启用存档。如果未启用归档,pgBackRest 将无法工作。
  1. $ psql -c "ALTER SYSTEM SET archive_mode TO 'ON'"
复制代码
archive_command : archive_command 必须设置为以下下令。这将由 pgBackRest 处理。
  1. $ psql -c "ALTER SYSTEM SET archive_command TO 'pgbackrest --stanza=pg1-server archive-push %p'"
复制代码
如果必须修改***archive_mode,***则大概必要重新启动 PostgreSQL 服务器。否则,重新加载就足够了。
以下是执行重新加载或 SIGHUP 的下令。
  1. $ pg_ctl -D /data/fbase/fbdata reload
复制代码
如果必要,以下是执行重新启动的下令。
  1. $ pg_ctl -D /data/fbase/fbdata restart -mf
复制代码
5.8 验证

在新存储库中创建节。必要在远程控制端进行初始化,在远程控制端完成初始化后,在再数据库端进行初始化。
repository 创建节
  1. [root@repository ~]# sudo -u pgbackrest  pgbackrest --stanza=demo stanza-create
  2. 如果出现以下错误,说明pgbackrest的权限不够
  3. ERROR: [050]: unable to acquire lock on file '/tmp/pgbackrest/demo-archive.lock': Permission denied
  4.        HINT: does 'pgbackrest:pgbackrest' running pgBackRest have permissions on the '/tmp/pgbackrest/demo-archive.lock' file?
  5. 执行一下命令可解决
  6. [root@repository pgbackrest]# chown -Rf pgbackrest:pgbackrest  /tmp/pgbackrest/
复制代码
检查数据库和存储库主机上的设置是否正确。
primary 检查设置
  1. sudo -u postgres
  2. pgbackrest --stanza=demo check
  3. [postgres@primary pgbackrest]$ pgbackrest --stanza=demo check
  4. 2024-08-02 14:40:00.010 CST [17226] LOG:  restore point "pgBackRest Archive Check" created at 0/7000228
  5. 2024-08-02 14:40:00.010 CST [17226] STATEMENT:  select pg_catalog.pg_create_restore_point('pgBackRest Archive Check')::text
复制代码
repository 检查设置
  1. sudo -u pgbackrest
  2. pgbackrest --stanza=demo check
复制代码
5.9 执行备份

要执行 PostgreSQL 集群的备份,请在存储库主机上利用 backup 下令运行 pgBackRest。
repository备份演示集群
  1. sudo -u pgbackrest
  2. pgbackrest --stanza=demo backup
  3. P00   WARN: no prior backup exists, incr backup has been changed to full
  4. 由于在存储库主机上创建了新的存储库,因此发出了有关增量备份更改为完整备份的警告。
复制代码
5.10 还原备份

要执行 PostgreSQL 集群的还原,请在数据库主机上利用 restore 下令运行 pgBackRest。
primary 停止演示集群,恢复并重启 PostgreSQL
  1. pg_ctl stop
  2. sudo -u postgres
  3. pgbackrest --stanza=demo --delta restore
  4. pg_ctl start
复制代码
5.11 问题总结

问题一 SSH怎么无需密码登录
在利用下令天生密钥的时候,输入密码时不要输入密码,直接按两下空格即可。
  1. ssh-keygen -t rsa -b 4096 -C "pgbackrest"
复制代码
而且有时候登录必要你输入postgres或者pgbackrest用户的密码。进行下面的步骤。
  1. # 查看用户是否需要密码,如果是LK的话最好是设置一下密码解锁
  2. sudo passwd -S postgres
  3. [root@primary ~]# sudo passwd -S postgres
  4. postgres PS 2024-08-02 0 99999 7 -1 (密码已设置,使用 SHA512 算法。)
  5. # 设置密码
  6. sudo passwd postgres
  7. # 解锁
  8. sudo passwd -u postgres
复制代码
还可以检查一下自己的SSH设置文件。
确保 /etc/ssh/sshd_config 文件中允许公钥认证并禁用密码认证:
  1. vi /etc/ssh/sshd_config
  2. # 修改配置
  3. PubkeyAuthentication yes
  4. PasswordAuthentication no
  5. # 重新启动 SSH 服务
  6. sudo systemctl restart sshd
复制代码
问题二 如果利用了python环境,大概导致lib库有依靠问题,进行创建SSH密钥的时候会报错
可以在环境变量的LD_LIBRARY_PATH路径。
  1. su - fbase
  2. vi ~/.bashrc
  3. export LD_LIBRARY_PATH=/usr/local/fbase/16.3/lib:$LD_LIBRARY_PATH
  4. # 修改为
  5. export LD_LIBRARY_PATH=/usr/lib64:/usr/local/fbase/16.3/lib:$LD_LIBRARY_PATH
  6. source ~/.bashrc
复制代码
必须将/usr/lib64放在第一个不然照旧会报依靠错误。但是如许也会导致psql下令无法利用,但是数据库照旧正常运行。
**问题三 ** 设置存储库主机时报错
  1. [pgbackrest@repository .ssh]$ pgbackrest --stanza=demo stanza-create
  2. WARN: unable to check pg1: [FileMissingError] raised from remote-0 ssh protocol on 'primary': unable to open missing file '/home/postgres/pgsql/data/global/pg_control' for read
  3. ERROR: [056]: unable to find primary cluster - cannot proceed
  4.        HINT: are all available clusters in recovery?
复制代码
这个问题是因为SSH的免密通道没有设置好,可以结合设置SSH和问题一的流程再次设置SSH密钥,可以将原来的密钥进行删除。
  1. su - postgres
  2. rm -rf /home/postgres/.ssh
  3. su - pgbackrest
  4. rm -rf /home/pgbackrest/.ssh
复制代码
问题四 repo1-retention-ful未设置
  1. [pgbackrest@repository .ssh]$ pgbackrest --stanza=demo backup
  2. WARN: option 'repo1-retention-full' is not set for 'repo1-retention-full-type=count', the repository may run out of space
  3.       HINT: to retain full backups indefinitely (without warning), set option 'repo1-retention-full' to the maximum.
  4. WARN: no prior backup exists, incr backup has been changed to full
复制代码
问题五 服务器处理libpq问题
  1. # 数据库服务器
  2. ln -s /usr/local/fbase/16.3/lib/libpq.so.5 /usr/lib64/libpq.so.5
  3. # 备份服务器
  4. ln -s /usr/local/fbase/16.3/lib/libpq.so.5 /usr/lib64/libpq.so.5
复制代码
6. 总结

6.1 pgbackRest特性

6.2 备份方式


附录

附录一 pgbackrest 常用下令

表3 pgbackrest 常用下令
下令表明示例backup创建数据库的备份
常用选项: `–type=fulldiffrestore从备份恢复数据库--delta:执行增量恢复,只恢复不同的文件。--target-xid=XID:恢复到指定事件 ID。 --target-time='YYYY-MM-DD HH:MM:SS':恢复到指定时间点。--target-name=restore-point-name:恢复到指定恢复点。pgbackrest --stanza=your-stanza-name restorearchive-push将 WAL 日志归档到备份存储pgbackrest --stanza=your-stanza-name archive-push /path/to/walarchive-get从备份存储中检索 WAL 日志。pgbackrest --stanza=your-stanza-name archive-getcheck检查设置和环境是否正确。pgbackrest --stanza=your-stanza-name checkinfo显示存储库中的备份信息。pgbackrest --stanza=your-stanza-name infoexpire删除过期的备份和存档文件。pgbackrest --stanza=your-stanza-name expirestanza-create创建一个新的存储仓(stanza)。--log-level-console=level:设置控制台日志级别(如 info, error, warn)。--repo-path=/path/to/repo:指定备份存储库路径。--pg1-path=/path/to/pgdata:指定 PostgreSQL 数据目录路径。--process-max=N:设置最大并行进程数pgbackrest --stanza=your-stanza-name stanza-createstanza-delete删除节,必要先停止数据库,指定repopgbackrest --stanza=demo --repo=1 --log-level-console=info stanza-delete 附录二 stanza可设置参数详解

表4 stanza可设置参数详解
参数表明示例pg-pathPostgreSQL 数据目录example: pg1-path=/data/dbpg-portPostgreSQL 端口default: 5432 allowed: 0-65535 example: pg1-port=6543pg-socket-path启动 PostgreSQL 时指定的 unix 套接字目录。example: pg1-socket-path=/var/run/postgresqlpg1-user连接到 PostgreSQL 时利用的数据库用户名。如果未指定,pgBackRest 将与本地操纵体系用户或 PGUSER 连接example: pg1-user=backupuserpg1-database连接到 PostgreSQL 时利用的数据库名称。默认值通常是最好的default: postgres
example: pg1-database=backupdbpg1-host用于远程操纵的 PostgreSQL 主机。example: pg1-host=db.domain.compg-host-ca-file利用体系默认值以外的 CA 文件连接到 PostgreSQL 主机example: pg1-host-ca-file=/etc/pki/tls/certs/ca-bundle.crtpg-host-ca-path利用体系默认路径以外的 CA 路径连接到 PostgreSQL 主机example: pg1-host-ca-path=/etc/pki/tls/certspg-host-cert-file发送到 PostgreSQL 主机以证实客户端身份example: pg1-host-cert-file=/path/to/client.crtpg-host-cmd仅当本地主机和 PostgreSQL 主机上 pgBackRest 下令的路径不同时,才必要。example: pg1-host-cmd=/usr/lib/backrest/bin/pgbackrestpg-host-config设置设置文件在 PostgreSQL 主机上的位置。default: CFGOPTDEF_CONFIG_PATH “/” PROJECT_CONFIG_FILE
example: pg1-host-config=/conf/pgbackrest/pgbackrest.confpg-host-config-include-path设置 PostgreSQL 主机上设置包罗路径的位置。default: CFGOPTDEF_CONFIG_PATH “/” PROJECT_CONFIG_INCLUDE_PATH example: pg1-host-config-include-path=/conf/pgbackrest/conf.dpg-host-config-path设置设置路径在 PostgreSQL 主机上的位置default: CFGOPTDEF_CONFIG_PATH example: pg1-host-config-path=/conf/pgbackrestpg-host-key-filePostgreSQL 主秘密钥文件。证实客户端证书是由全部者发送的。example: pg1-host-key-file=/path/to/client.keypg-host-port设置 pg-host 时的 PostgreSQL 主机端口。allowed: 0-65535 example: pg1-host-port=25pg-host-typePostgreSQL 主机协议范例default: ssh example: pg1-host-type=tlspg-host-user设置 pg-host 时的 PostgreSQL 主机登录用户。default: postgres example: pg1-host-user=db_owner pgBackRest 设置文件遵循 Windows INI 约定。各部门用括号中的文本表示,每个部门都包罗键/值对。以 # 开头的行将被忽略,并可用作注释。
可以通过多种方式加载 pgBackRest 设置文件:

pgBackRest 也可以利用环境变量进行设置,如下.
pg-primary 利用环境设置日志路径
  1. sudo -u postgres bash -c ' \
  2.        export PGBACKREST_LOG_PATH=/var/log/pgbackrest && \
  3.        pgbackrest --log-level-console=error help backup log-path'
  4.      
  5. help  backup  log-path 显示log-path的指导文档
复制代码
附录三 存储库的常用参数

表5 有关存储库的常用参数
参数表明示例repo设置要操纵的下令的存储库。此选项可用于从特定存储库执行还原,而不是让 pgBackRest 选择allowed: 1-256 example: repo=1repo-bundle将文件捆绑在存储库中。捆绑(归并)较小的文件以减少写入存储库的文件总数。写入更少的文件通常效率更高default: n example: repo1-bundle=yrepo-bundle-limit将包罗在捆绑包中的文件的大小限定。大于此大小的文件将单独存储。default: 2MiB allowed: 8KiB-1PiB example: repo1-bundle-limit=10MiBrepo-bundle-size定义将添加到单个捆绑包的文件的总大小。大多数捆绑包将小于此大小,但有些捆绑包大概会稍大一些,因此请勿将此选项设置为文件体系允许的最大大小default: 20MiB allowed: 1MiB-1PiB example: repo1-bundle-size=10MiBrepo-block启用块增量备份。块增量通过将文件拆分为可以独立备份的块,允许更精细的备份。如允许以节省存储库中的空间,而且可以提高增量还原性能,因为可以在不从存储库读取整个文件的环境下获取单个块。default: n example: repo1-block=yrepo-cipher-pass用于加密/解密存储库文件的密码。可以用openssl rand -base64 48获取随机加密字符串repo-cipher-type指定加密范例default: none example: repo1-cipher-type=aes-256-cbcrepo-host远程操纵时的存储库主机。example: repo1-host=repo1.domain.comrepo-host-cmd存储库主机 pgBackRest 下令。example: repo1-host-cmd=/usr/lib/backrest/bin/pgbackrestrepo-host-configpgBackRest 存储库主机设置文件default: CFGOPTDEF_CONFIG_PATH “/” PROJECT_CONFIG_FILE example: repo1-host-config=/conf/pgbackrest/pgbackrest.confrepo-host-config-pathpgBackRest 存储库主机设置路径。default: CFGOPTDEF_CONFIG_PATH example: repo1-host-config-path=/conf/pgbackrestrepo-host-user存储库主机用户(如果设置了 repo-host)default: pgbackrest example: repo1-host-user=repo-userrepo-path存储备份和存档的路径。default: /var/lib/pgbackrest example: repo1-path=/backup/db/backrestrepo-retention-archive要保留的一连 WAL 的备份数。如果 repo-retention-archive-type 设置为 incr,则必须设置此选项。如果磁盘空间非常宝贵,则此设置与 repo-retention-archive-type 结合利用,可用于主动使 WAL 段过期。但是,如许做会否定从具有过期 WAL 的备份执行 PITR 的功能,因此发起如许做。allowed: 1-9999999 example: repo1-retention-archive=2repo-retention-archive-typeWAL 保留的备份范例default: full example: repo1-retention-archive-type=diffrepo1-retention-full-type完整备份的保留范例。如果设置为 time,则将从存储库中删除早于 repo-retention-full 的完整备份。如果设置为count,高出count份时则保留后面count份删除最早的一份default: count example: repo1-retention-full-type=timerepo-retention-diff要保留的差别备份数。allowed: 1-9999999 example: repo1-retention-diff=3repo-retention-full完整备份保留计数/时间。allowed: 1-9999999 example: repo1-retention-full=2
  1.                | default: /var/lib/pgbackrest example: repo1-path=/backup/db/backrest |
复制代码
| repo-retention-archive | 要保留的一连 WAL 的备份数。如果 repo-retention-archive-type 设置为 incr,则必须设置此选项。如果磁盘空间非常宝贵,则此设置与 repo-retention-archive-type 结合利用,可用于主动使 WAL 段过期。但是,如许做会否定从具有过期 WAL 的备份执行 PITR 的功能,因此发起如许做。 | allowed: 1-9999999 example: repo1-retention-archive=2 |
| repo-retention-archive-type | WAL 保留的备份范例 | default: full example: repo1-retention-archive-type=diff |
| repo1-retention-full-type | 完整备份的保留范例。如果设置为 time,则将从存储库中删除早于 repo-retention-full 的完整备份。如果设置为count,高出count份时则保留后面count份删除最早的一份 | default: count example: repo1-retention-full-type=time |
| repo-retention-diff | 要保留的差别备份数。 | allowed: 1-9999999 example: repo1-retention-diff=3 |
| repo-retention-full | 完整备份保留计数/时间。 | allowed: 1-9999999 example: repo1-retention-full=2 |

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com (https://dis.qidao123.com/) Powered by Discuz! X3.4