PostgreSQL备份工具之pg_rman
pg_rman is an online backup and restore tool for PostgreSQL.Oracle它的备份工具rman是非常强大的,多年前就已经支持全量、增量、归档的备份模式,支持压缩等;还支持元数据存储到数据库中,管理也非常的方便,例如保留多少归档,备份集的管理也很方便,例如要恢复到什么时间点,将此前的备份清除等等。采用C语言开发并在BSD协议下授权。
与Oracle相比,其它开源软件基本都未自带物理备份软件或者功能不够完整,要实现物理备份需借助三方插件完成。Postgresql虽然自带pg_basebackup,但是不支持增量备份。pg_rman是pgsql众多三方备份插件之一,其支持全量备份、增量备份、归档备份压缩等,类似于oracle rman。
The goal of the pg_rman project is to provide a method for online backup and PITR that is as easy as pg_dump. Also, it maintains a backup catalog per database cluster. Users can maintain old backups including archive logs with one command.
可在项目主页上下载对应pg版本的rpm文件或者源码包文件,依赖于zlib-devel包,所以需提前安装。源码安装方法如下:
make && make install
测试
make installcheck
pg_rman使用的是pg_start_backup(),copy,pg_stop_backup()的备份模式。pg_rman不是流复制协议而是文件拷贝,所以pg_rman必须和数据库节点跑在一起。如果在standby节点跑pg_rman,pg_rman则需要通过网络连接到主节点执行pg_start_backup和pg_stop_backup。
pg_rman的用法非常简单,支持以下几种运行模式:
init Initialize a backup catalog.
backup Take an online backup.
restore Do restore.
show Show backup history. The detail option shows with additional information of each backups.
validate Validate backup files. Backups without validation cannot be used for restore and incremental backup.
delete Delete backup files.
purge Remove deleted backups from backup catalog.
命令行用法
pg_rman manage backup/recovery of PostgreSQL database.
Usage:
pg_rman OPTION init
pg_rman OPTION backup
pg_rman OPTION restore
pg_rman OPTION show [DATE]
pg_rman OPTION show detail [DATE]
pg_rman OPTION validate [DATE]
pg_rman OPTION delete DATE
pg_rman OPTION purge
Common Options:
-D, --pgdata=PATH location of the database storage area
-A, --arclog-path=PATH location of archive WAL storage area
-S, --srvlog-path=PATH location of server log storage area
-B, --backup-path=PATH location of the backup storage area
-c, --check show what would have been done
-v, --verbose show what detail messages
-P, --progress show progress of processed files
Backup options:
-b, --backup-mode=MODE full, incremental, or archive
-s, --with-serverlog also backup server log files
-Z, --compress-data compress data backup with zlib
-C, --smooth-checkpoint do smooth checkpoint before backup
-F, --full-backup-on-error switch to full backup mode if pg_rman cannot find validate full backup on current timeline
NOTE: this option is only used in --backup-mode=incremental or archive.
--keep-data-generations=NUM keep NUM generations of full data backup
--keep-data-days=NUM keep enough data backup to recover to N days ago
--keep-arclog-files=NUM keep NUM of archived WAL
--keep-arclog-days=DAY keep archived WAL modified in DAY days
--keep-srvlog-files=NUM keep NUM of serverlogs
--keep-srvlog-days=DAY keep serverlog modified in DAY days
--standby-host=HOSTNAME standby host when taking backup from standby
--standby-port=PORT standby port when taking backup from standby
Restore options:
--recovery-target-time time stamp up to which recovery will proceed
--recovery-target-xid transaction ID up to which recovery will proceed
--recovery-target-inclusive whether we stop just after the recovery target
--recovery-target-timeline recovering into a particular timeline
--hard-copy copying archivelog not symbolic link
Catalog options:
-a, --show-all show deleted backup too
Delete options:
-f, --force forcibly delete backup older than given DATE
Connection options:
-d, --dbname=DBNAME database to connect
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port
-U, --username=USERNAME user name to connect as
-w, --no-password never prompt for password
-W, --password force password prompt
Generic options:
-q, --quiet don't show any INFO or DEBUG messages
--debug show DEBUG messages
--help show this help, then exit
--version output version information, then exit
使用pg_rman的前置条件
开启归档
配置csvlog
Pg数据库要进行物理备份跟oracle一样,需开启归档功能,操作步骤如下:
alter system set wal_level='replica';
alter system set archive_mode='on';
alter system set archive_command = 'cp %p .../archive/%f';
postgres=# show log_destination ;
log_destination
-----------------
csvlog
postgres=# SHOW log_directory;
log_directory
---------------
pg_log
postgres=# SHOW archive_command;
archive_command
--------------------------------------------
cp %p /data04/digoal/arc_log/%f
重启数据库。开始备份前,还需进行catalog初始化,用于保存备份信息,类似oracle控制文件或者catalog里保留的备份信息,命令如下:
pg_rmaninit -B backup
$ pg_rman init
WARNING:ARCLOG_PATH is not set yet
DETAIL:The archive_command is not set in postgresql.conf.
HINT:Please set ARCLOG_PATH in pg_rman.ini or environmental variable.
INFO:SRVLOG_PATH is set to '/data/pgdata1/pg_log'
完成catalog初始化后,即可开始数据库备份。值得说明的是在catalog中有pg_rman.ini文件,可配置备份的环境变量、备份选项、备份集保留期限等信息,其功能类似oracle rman 的configure和showall。
pg_rman.ini示例:
$cat pg_rman.ini
ARCLOG_PATH='/backup/freeoa_arch'
SRVLOG_PATH='/data/freeoa_data/log'
初始化pg_rman backup catalog
首先需要初始化一个backup catalog,实际上就是需要一个目录,这个目录将用于存放备份的文件。同时这个目录也会存放一些元数据,例如备份的配置文件,数据库的systemid,时间线文件历史等等。初始化命令需要两个参数,分别为备份目标目录,以及数据库的$PGDATA。
$ mkdir/pgbbk
$ pg_rman init -B /pgbbk -D /pg_root
INFO: ARCLOG_PATH is set to '/arc_log'
INFO: SRVLOG_PATH is set to '/pg_root/pg_log'
生成备份元数据如下
$ cd /pgbbk/
backup
pg_rman.ini
system_identifier
timeline_history
生成的配置文件
$ cat pg_rman.ini
ARCLOG_PATH='/arc_log'
SRVLOG_PATH='/pg_root/pg_log'
可以把将来要使用的配置写在这个配置文件中,或者写在pg_rman的命令行中,后面的测试会直接使用命令行参数。生成的数据库system id,用于区分备份的数据库是不是一个数据库,防止被冲。
$ cat system_identifier
SYSTEM_IDENTIFIER='6318621837015461309'
与控制文件中存储的system id一致。
注意:pg_rman只从postgresql.conf取log_directory和archive_command参数的值。如果PostgreSQL的配置文件是include的或者配置在postgresql.auto.conf中,这两个值将不准确。所以建议仅仅把参数配置在postgresql.conf中,而不要使用其他配置文件。
-------------------------------
全量备份
$ pg_rman backup
-B /pgbbk -D /pg_root
-b full -s -Z -C
--keep-data-days=10
--keep-arclog-files=15
--keep-arclog-days=10
--keep-srvlog-files=10
--keep-srvlog-days=15
-h 127.0.0.1 -p 1921 -U postgres -d postgres
$ pg_rman backup -b full -A pg_archivelog
INFO:copying database files
INFO:copying archived WAL files
INFO:backup complete
INFO:Please execute 'pg_rman validate' to verify the files are correctlycopied.
$ pg_rman show
=====================================================================
StartTime EndTime Mode Size TLI Status
=====================================================================
2020-10-2516:24:17 2020-10-25 16:24:20 FULL 95MB 1 DONE
可看出备份成功后,其状态是done,还需要进行validate操作后,备份集才可用于恢复,增量备份才会用于做对比。备份时pg_rman会记录每个备份文件的crc,以便validate进行校验。
文件类似于:
base/1/113 f 57 1147028285 0600 2019-07-28 10:03:02
表示了路径,文件类型,大小,CRC校验值,权限,时间,第四列即crc校验值
每次备份完,必须要做一次校验,否则备份集不可用用来恢复,增量备份时也不会用它来做增量比较。每个备份集都包含了一个备份状态文件,如下:
cat /pgbbk/20160826/201955/backup.ini
# configuration
BACKUP_MODE=INCREMENTAL
FULL_BACKUP_ON_ERROR=false
WITH_SERVERLOG=true
COMPRESS_DATA=true
# result
TIMELINEID=1
START_LSN=46/df000108
STOP_LSN=46/df000210
START_TIME='2019-08-26 20:19:55'
END_TIME='2019-08-26 20:20:48'
RECOVERY_XID=3896508593
RECOVERY_TIME='2019-08-26 20:20:47'
TOTAL_DATA_BYTES=6196524307
READ_DATA_BYTES=3199287520
READ_ARCLOG_BYTES=33554754
READ_SRVLOG_BYTES=0
WRITE_BYTES=125955
BLOCK_SIZE=8192
XLOG_BLOCK_SIZE=8192
STATUS=OK
这个文件中包含了很重要的信息,比如LSN,后面LSN将用于比对增量备份时对比数据块的LSN是否发生了变化,是否需要备份。
$ pg_rman validate
INFO:validate: "2020-10-25 16:24:17" backup and archive logfiles by CRC
INFO:backup "2020-10-25 16:24:17" is valid
$ pg_rman show detail
======================================================================================================================
StartTime EndTime Mode Data ArcLog SrvLog Total Compressed CurTLI ParentTLI Status
======================================================================================================================
2020-10-2516:24:17 2020-10-25 16:24:20 FULL 41MB 67MB ---- 95MB false 1 0 OK
--validate校验完成后,其备份集状态变成OK。
-------------------------------
增量备份
PostgreSQL增量备份是怎么做到的呢?一个数据页的框架如下:
* +----------------+---------------------------------+
* | PageHeaderData | linp1 linp2 linp3 ... |
* +-----------+----+---------------------------------+
* | ... linpN | |
* +-----------+--------------------------------------+
* | ^ pd_lower |
* | |
* | v pd_upper |
* +-------------+------------------------------------+
* | | tupleN ... |
* +-------------+------------------+-----------------+
* | ... tuple3 tuple2 tuple1 | "special space" |
* +--------------------------------+-----------------+
数据页头部的数据结构
typedef struct PageHeaderData {
/* XXX LSN is member of *any* block, not only page-organized ones */
PageXLogRecPtr pd_lsn; /* LSN: next byte after last byte of xlog
* record for last change to this page */
uint16 pd_checksum; /* checksum */
uint16 pd_flags; /* flag bits, see below */
LocationIndex pd_lower; /* offset to start of free space */
LocationIndex pd_upper; /* offset to end of free space */
LocationIndex pd_special; /* offset to start of special space */
uint16 pd_pagesize_version;
TransactionId pd_prune_xid; /* oldest prunable XID, or zero if none */
ItemIdData pd_linp[FLEXIBLE_ARRAY_MEMBER]; /* line pointer array */
} PageHeaderData;
因为如果对象是持久化的,那么它的所有变更都会记录REDO,数据页头部的pd_lsn表示该数据页最后一次变化时,变化产生的REDO在xlog file中的结束位置。即如果xlog flush的xlog地址位 大于或等于 此页pd_lsn,那么这个页的更改就可以认为是可靠的。
* pd_lsn - identifies xlog record for last change to this page.
* pd_checksum - page checksum, if set.
* pd_flags - flag bits.
* pd_lower - offset to start of free space.
* pd_upper - offset to end of free space.
* pd_special - offset to start of special space.
* pd_pagesize_version - size in bytes and page layout version number.
* pd_prune_xid - oldest XID among potentially prunable tuples on page.
既然每次块的变化都包含了LSN的修改,那么也即是说,可以通过第一次备份开始时的全局LSN,以及当前需要备份的数据的page LSN来判断此页是否发生过修改。如果修改了就备份,没修改就不需要备份,从而实现数据库的块级增量备份。
pg_rman backup -B /pgbbk -D /pg_root
-b incremental -s -Z -C
--keep-data-days=10
--keep-arclog-files=15
--keep-arclog-days=10
--keep-srvlog-files=10
--keep-srvlog-days=15
-h 127.0.0.1 -p 1921 -U postgres -d postgres
$ pg_rmanbackup -b incremental -A pg_archivelog
校验备份集
$ pg_rman validate -B /pgbbk
列出备份集
$ pg_rman show -B /pgbbk
==========================================================
StartTime Mode Duration Size TLI Status
==========================================================
2019-08-26 19:43:20 INCR 0m 54kB 1 OK
2019-08-26 19:39:50 FULL 1m 235MB 1 OK
可以看到增量非常小,因为很少变化的块。
备份脚本
在生产环境中,需制定备份策略,通常每周全备,每天增量,同时备份归档日志,备份脚本示例:
每周日全备,其他时间进行增量备份
#/bin/bash
.~/.bash_profile
current_path=`dirname$0`
export PGPASSWORD'xxx'
export BACKUP_PATH=/backup***_back
LOCAL_HOST='ipaddr'
LOCAL_PORT=5432
BACK_DAY=6
#主库角色备份
master_backup(){
echo"master_backup"
pg_rmanbackup --backup-mode=$1 -Z -F -h ${LOCAL_HOST} -p ${LOCAL_PORT}--with-serverlog --keep-srvlog-days=7 --keep-data-generations=1--keep-arclog-files=100 --keep-arclog-days=1 -U postgres -Pv
#写入文件短信告警
if[[ $? -ne 0 ]]; then
echo`date '+%y-%m-%d %H:%M:%S': ` $1 "backup failed!" >${current_path}/backupflag
else
echo`date '+%y-%m-%d %H:%M:%S': ` $1 "backup successful!" >${current_path}/backupflag
pg_rmanvalidate
pg_rmanpurge
fi
}
#从库角色备份
slave_backup(){
echo"slave_backup"
pg_rmanbackup --backup-mode=$1 -Z -F -h $2 -p $3--standby-host=${LOCAL_HOST} --standby-port=${LOCAL_PORT}--with-serverlog --keep-srvlog-days=7 --keep-data-generations=1--keep-arclog-files=100 --keep-arclog-days=1 -U postgres -Pv
#写入文件短信告警
if[[ $? -ne 0 ]]; then
echo`date '+%y-%m-%d %H:%M:%S': ` $1 "backup failed!" >${current_path}/backupflag
else
echo`date '+%y-%m-%d %H:%M:%S': ` $1 "backup successful!" >${current_path}/backupflag
pg_rmanvalidate
pg_rmanpurge
fi
}
#判断日期,如周六全备,其它时间备份归档,若没有全量备份则做全量备份
fullback_stat=`pg_rmanshow |grep "FULL"|awk '{print $8}'`
weekday=`date+%w`
if[[ ${fullback_stat} =~ "OK" ]]; then
if[[ ${weekday} -eq ${BACK_DAY} ]]; then
back_mode='full'
else
back_mode='incremental'
fi
else
back_mode='full'
fi
#数据库进程情况
is_alive=`pg_isready -p ${LOCAL_PORT}|grep "accepting"|wc -l`
if[[ $is_alive -eq 0 ]]; then
echo"database is down"
else
#主从
is_recovery=`psql-t -c "SELECT pg_is_in_recovery();"`
echo${is_recovery}
if[[ ${is_recovery} =~ "t" ]]; then
masterhost=`psql-t -c "select sender_host from pg_stat_wal_receiver;"`
masterport=`psql-t -c "select sender_port from pg_stat_wal_receiver;"`
logger-i "slave_backup will be running"
slave_backup${back_mode} ${masterhost} ${masterport}
else
logger-i "master_backup will be running"
master_backup${back_mode}
fi
fi
恢复
pg_rman数据恢复时的两个必要要素
新的$PGDATA
备份目录
命令的选项也很简单,甚至可以不指定任何option
Restore options:
The parameters which are started with –recovery are same as parameters in recovery.conf.
接下来的几个配置,与recovery.conf的意思对齐。如果不指定时间线,则使用$PGDATA/global/pg_control,如果没有$PGDATA/global/pg_control,则使用最新的全量备份集的时间线。
--recovery-target-timeline TIMELINE
Specifies recovering into a particular timeline. If not specified, the current timeline from ($PGDATA/global/pg_control) is used.
如果不指定,则恢复到最新时间
--recovery-target-time TIMESTAMP
This parameter specifies the time stamp up to which recovery will proceed. If not specified, continue recovery to the latest time.
如果不指定,则恢复到最新xid
--recovery-target-xid XID
This parameter specifies the transaction ID up to which recovery will proceed. If not specified, continue recovery to the latest xid.
如果不指定,则默认使用true,即恢复到包含恢复目标XID的commit record为止,或者第一笔commit record ts>指定ts的 commit redo record为止;如果是false则不apply恢复目标XID的commit record,或者不apply第一笔commit record ts>=指定ts的 commit redo record。
--recovery-target-inclusive
Specifies whether we stop just after the specified recovery target (true), or just before the recovery target (false). Default is true.
是否使用硬链接复制archive log,而不需要拷贝文件
The following parameter determines the behavior of restore.
--hard-copy
The archive WAL are copied to archive WAL storage area. If not specified, pg_rman makes symbolic link to archive WAL where are in the backup catalog directory.
恢复时需要注意,可以选择原地恢复(覆盖式),或者使用新的$PGDATA作为恢复目标。但是请注意,不管是哪种恢复方式,如果在本机恢复的话,pg_rman可能会覆盖原有的数据文件,arch,pg_xlog目录中的文件,所以如果要保留原数据,建议先将原数据目录重命名。
原地恢复
使用新的$PGDATA恢复
在本机恢复的例子
1. 停库
pg_ctl stop -m fast -D /pg_root_1922
2. 重命名原数据相关目录
mv /pg_root_1922 /old_pg_root_1922
PG_XLOG
mv /pg_xlog_1922 /old_pg_xlog_1922
表空间
mv /tbs1_1922 /old_tbs1_1922
归档目录,除了要重命名,还需要新建一个原目录
mv /arc_log1922 /old_arc_log1922
mkdir /arc_log1922
...
3. pg_rman restore
4. 修改postgresql.conf, recovery.conf
根据实际情况调整
5. 如果备份集的时间线发生了变化,需要先手工拷贝到归档目录,再执行restore
6. 启动恢复目标数据库
pg_ctl start -D /pg_restore_root
注意事项
小心覆盖原有的部分,建议先将原有的目录重命名,或者在其他机器恢复,软链接的处理,会恢复到目标,并且重新建立软链接,所以目录结构必须与备份时保持一致。
用户可以指定$PGDATA,恢复到新的目标目录,但是arch_log, 表空间, pg_xlog目录无法指定新的位置,所以原地还原时,必须注意这些目录可能被覆盖,先重命名是比较好的手段。
备份参数-C表示无缝checkpoint,所以可能很慢,视checkpoint_completion_target和segment_size的配置。如果发现pg_rman开始很慢,可以把-C去掉,速度就快了,但是可能在高峰时,造成冲击。建议高峰是不要备份。
一例通过试验验证pg_rman的基础使用
创建测试环境
模拟创建新表空间,新数据库,新用户,新schema,并且创建表插入测试数据,这样的环境下,pg_rman 备份还原效果
[root@localhost ~]# psql
Password:
psql.bin (10.4)
postgres=# CREATE USER u_freeoa WITH LOGIN SUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION
postgres-# CONNECTION LIMIT -1 PASSWORD 'freeoa';
postgres=# CREATE TABLESPACE tbs_freeoa OWNER u_freeoa
postgres-# LOCATION '/opt/PostgreSQL/10/tbs_freeoa';
postgres=# CREATE DATABASE db_freeoa WITH OWNER = u_freeoa ENCODING = 'UTF8' TABLESPACE = tbs_freeoa CONNECTION LIMIT = -1;
[root@localhost ~]# psql -U u_freeoa
Password for user u_freeoa:
psql.bin (10.4)
Type "help" for help.
postgres=# \q
[root@localhost ~]# psql -U u_freeoa -d db_freeoa
Password for user u_freeoa:
db_freeoa=# create schema u_freeoa;
CREATE SCHEMA
db_freeoa=# create table t_freeoa as select * from pg_tables;
SELECT 69
db_freeoa=# insert into t_freeoa select * from t_freeoa;
INSERT 0 69
...
db_freeoa=# insert into t_freeoa select * from t_freeoa;
INSERT 0 565248
db_freeoa=# select count(*) from t_freeoa;
count
---------
1130496
第一次全备数据库
[root@localhost backup]# pg_rman backup --backup-mode=full --backup-path=/backup -d db_freeoa -U u_freeoa -h 127.0.0.1
Password for user u_freeoa:
INFO: copying database files
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
模拟继续插入数据
t_freeoa表一共有数据2260992条
b_freeoa=# insert into t_freeoa select * from t_freeoa;
INSERT 0 1130496
db_freeoa=# select count(*) from t_freeoa;
count
---------
2260992
查看全备情况
[root@localhost 10]# pg_rman show --backup-path=/backup
=====================================================================
StartTime EndTime Mode Size TLI Status
=====================================================================
2018-08-05 10:47:29 2018-08-05 10:47:43 FULL 611MB 1 DONE
备份归档日志
[root@localhost 10]# pg_rman backup --backup-mode=archive --backup-path=/backup -d db_freeoa -U u_freeoa -h 127.0.0.1
Password for user u_freeoa:
INFO: copying archived WAL files
INFO: backup complete
INFO: Please execute 'pg_rman validate' to verify the files are correctly copied.
检查全备和归档备份情况
[root@localhost 10]# pg_rman show --backup-path=/backup
=====================================================================
StartTime EndTime Mode Size TLI Status
=====================================================================
2018-08-05 10:54:51 2018-08-05 10:56:07 ARCH 620MB 1 DONE
2018-08-05 10:47:29 2018-08-05 10:47:43 FULL 611MB 1 DONE
停掉pg
[root@localhost data]# su - postgres
Last login: Sun Aug 5 02:19:57 EDT 2018 on pts/1
$ source pg_env.sh
$ pg_ctl stop
waiting for server to shut down.... done
server stopped
删除原库并创建相关目录
注意:对应的空间目录权限为700,所有者和组为postgres
[root@localhost 10]# pwd
/opt/PostgreSQL/10
[root@localhost 10]# mv data data_bak
[root@localhost 10]# mv tbs_freeoa tbs_freeoa_bak
[root@localhost 10]# mkdir data
[root@localhost 10]# mkdir tbs_freeoa
[root@localhost 10]# chmod 700 data
[root@localhost 10]# chmod 700 tbs_freeoa
[root@localhost 10]# chown postgres:postgres data
[root@localhost 10]# chown postgres:postgres tbs_freeoa
还原数据库
$ pg_rman restore --backup-path=/backup
WARNING: pg_controldata file "/opt/PostgreSQL/10/data/global/pg_control" does not exist
INFO: the recovery target timeline ID is not given
INFO: use timeline ID of latest full backup as recovery target: 1
INFO: calculating timeline branches to be used to recovery target point
INFO: searching latest full backup which can be used as restore start point
INFO: found the full backup can be used as base in recovery: "2018-08-05 10:47:29"
INFO: copying online WAL files and server log files
INFO: clearing restore destination
INFO: validate: "2018-08-05 10:47:29" backup and archive log files by SIZE
INFO: backup "2018-08-05 10:47:29" is valid
INFO: restoring database files from the full mode backup "2018-08-05 10:47:29"
INFO: searching incremental backup to be restored
INFO: searching backup which contained archived WAL files to be restored
INFO: backup "2018-08-05 10:47:29" is valid
INFO: restoring WAL files from backup "2018-08-05 10:47:29"
INFO: restoring online WAL files and server log files
INFO: generating recovery.conf
INFO: restore complete
HINT: Recovery will start automatically when the PostgreSQL server is started.
启动pg
$ pg_ctl start
waiting for server to start....2018-08-05 11:23:40.190 EDT [40855] LOG: listening on IPv4 address "0.0.0.0", port 5432
2018-08-05 11:23:40.190 EDT [40855] LOG: listening on IPv6 address "::", port 5432
2018-08-05 11:23:40.193 EDT [40855] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2018-08-05 11:23:40.200 EDT [40855] LOG: redirecting log output to logging collector process
2018-08-05 11:23:40.200 EDT [40855] HINT: Future log output will appear in directory "log".
done
server started
$ ps -ef|grep postgres
root 40328 21806 0 11:14 pts/3 00:00:00 su - postgres
postgres 40329 40328 0 11:14 pts/3 00:00:00 -bash
postgres 40855 1 0 11:23 pts/3 00:00:00 /opt/PostgreSQL/10/bin/postgres
postgres 40856 40855 0 11:23 ? 00:00:00 postgres: logger process
postgres 40857 40855 57 11:23 ? 00:00:16 postgres: startup process waiting for 000000010000000000000025
postgres 40859 40855 0 11:23 ? 00:00:00 postgres: checkpointer process
postgres 40860 40855 7 11:23 ? 00:00:02 postgres: writer process
postgres 40862 40855 0 11:23 ? 00:00:00 postgres: stats collector process
postgres 40892 40329 0 11:24 pts/3 00:00:00 ps -ef
postgres 40893 40329 0 11:24 pts/3 00:00:00 grep --color=auto postgres
简单验证数据库还原结果
$ psql -U u_freeoa -d db_freeoa
Password for user u_freeoa:
psql.bin (10.4)
db_freeoa=# select count(*) from t_freeoa;
count
---------
2260992
(1 row)
破坏环境之前表条数和还原之后完全匹配,证明pg_rman在功能上备份恢复没有问题。
最新版本:1.3.11
项目主页:https://github.com/ossc-db/pg_rman