PostgreSQL备份工具 - PgBackRest安装部署使用

1. 安装依赖、下载安装包

# 依赖工具库
[root@hhb ~]# yum -y install gcc make zlib-devel libxm12-devel openssl-devel bzip2-devel libxml2-devel lz4-devel libzstd-devel libyaml-devel
# 下载安装包
[root@hhb ~]# wget https://github.com/pgbackrest/pgbackrest/archive/release/2.45.tar.gz

2. 编译安装

# 解压
[root@hhb postgresql]# tar -zxvf pgbackrest-release-2.45.tar.gz
[root@hhb postgresql]# chown -R pg143:pg143 pgbackrest-release-2.45
[root@hhb postgresql]# cd pgbackrest-release-2.45/src/

## 创建目录
[root@hhb postgresql]# mkdir -p /opt/pg143/pgbackrest/{conf,log}
[root@hhb postgresql]# chown -R pg143:pg143 /opt/pg143/pgbackrest

## 编译安装
[root@hhb postgresql]# cd pgbackrest-release-2.45/src/
# prefix可以指定也可以不指定,,指定目录和当前src目录都会产生pgbackrest
[root@hhb src]# ./configure --prefix=/opt/pg143/pgbackrest
[root@hhb src]# make -j24 && make install -j24
# 直接放到pg环境中
[root@hhb src]# cp /opt/pg143/pgbackrest/bin/pgbackrest /opt/pg143/postgresql/bin/
[root@hhb src]# chown -R pg143:pg143 /opt/pg143/pgbackrest/bin/pgbackrest
[root@hhb src]# chown -R pg143:pg143 /opt/pg143/pgbackrest

# 简单验证
# 
[root@hhb src]# su - pg143
[pg143@hhb ~]$ pgbackrest
pgBackRest 2.45 - General help

Usage:
    pgbackrest [options] [command]

Commands:
    annotate        Add or modify backup annotation.
    archive-get     Get a WAL segment from the archive.
    archive-push    Push a WAL segment to the archive.
    backup          Backup a database cluster.
    check           Check the configuration.
    expire          Expire backups that exceed retention.
    help            Get help.
    info            Retrieve information about backups.
    repo-get        Get a file from a repository.
    repo-ls         List files in a repository.
    restore         Restore a database cluster.
    server          pgBackRest server.
    server-ping     Ping pgBackRest server.
    stanza-create   Create the required stanza data.
    stanza-delete   Delete a stanza.
    stanza-upgrade  Upgrade a stanza.
    start           Allow pgBackRest processes to run.
    stop            Stop pgBackRest processes from running.
    verify          Verify contents of the repository.
    version         Get version.

Use 'pgbackrest help [command]' for more information.

3. 配置参数

# 创建备份目录
[pg143@hhb ~]$ mkdir -p /opt/pg143/backup
[root@hhb ~]# mkdir -p /var/spool/pgbackrest
[root@hhb ~]# chown -R pg143:pg143 /var/spool/pgbackrest

# 配置参数
[参数文档](https://pgbackrest.org/configuration.html)
[pg143@hhb ~]$ cat /opt/pg143/pgbackrest/conf/pgbackrest.conf
[global]
# 备份存储目录
repo1-path=/opt/pg143/backup
# 备份日志位置
log-path=/opt/pg143/pgbackrest/log
# 保留全库备份个数
repo1-retention-full=2
# 立即执行检查点,否则,备份将在下一个常规检查点之后开始。
start-fast=y
# 配置异步归档,异步操作更高效,因为它可以重用连接并利用并行性。
archive-async=y

[pg143]
pg1-path=/opt/pg143/data
# pg1-host=152.136.156.227
pg1-user=sa
pg1-port=
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值