postgresql运维—pg_rman安装及使用说明
pg_rman 说明
pg_rman 是 postgresql 的在线备份和恢复工具。类似oracle 的 rman
pg_rman 项目的目标是提供一种与 pg_dump 一样简单的在线备份和 pitr 方法。此外,它还为每个数据库集群维护一个备份目录。用户可以使用一个命令维护旧备份,包括存档日志。
今天我们来学习一下pg_rman 工具的安装及使用。
pg_rman安装
软件下载
安装包下载地址: 墨天轮地址:https://www.modb.pro/download/438831 gitlb地址:https://github.com/ossc-db/pg_rman
安装准备
解压压缩包
[postgres@lyp plug-in]$ ls -lrt pg_rman-master.zip
-rw-r--r--. 1 postgres postgres 148651 feb 17 20:04 pg_rman-master.zip
[postgres@lyp plug-in]$ unzip pg_rman-master.zip
archive: pg_rman-master.zip
59b3bca1338d3fe48eba2395b81ec69de534eabf
creating: pg_rman-master/
creating: pg_rman-master/.github/
..........
inflating: pg_rman-master/validate.c
inflating: pg_rman-master/xlog.c
[postgres@lyp plug-in]$
要编译并安装“pg_rman”,请阅读文件“readme.md”,然后按照其中包含的指示和建议进行编译安装pg_rman。
安装软件
[postgres@lyp pg_rman-master]$ make
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o backup.o backup.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o catalog.o catalog.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o data.o data.c
data.c: in function 鈥1mfigure_out_segno鈥[01mdata.c:1270:8: warning: variable 鈥1mscanned鈥t but not used [-wunused-but-set-variable]
int scanned;
^
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o delete.o delete.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o dir.o dir.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o init.o init.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o parray.o parray.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o pg_rman.o pg_rman.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o restore.o restore.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o show.o show.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o util.o util.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o validate.o validate.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o xlog.o xlog.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o pgsql_src/pg_ctl.o pgsql_src/pg_ctl.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o pgut/pgut.o pgut/pgut.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 -i/opt/pgsql14.1/include -lm -i. -i./ -i/opt/pgsql14.1/include/server -i/opt/pgsql14.1/include/internal -d_gnu_source -c -o pgut/pgut-port.o pgut/pgut-port.c
gcc -std=gnu99 -wall -wmissing-prototypes -wpointer-arith -wdeclaration-after-statement -werror=vla -wendif-labels -wmissing-format-attribute -wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard -o2 backup.o catalog.o data.o delete.o dir.o init.o parray.o pg_rman.o restore.o show.o util.o validate.o xlog.o pgsql_src/pg_ctl.o pgut/pgut.o pgut/pgut-port.o -l/opt/pgsql14.1/lib -wl,--as-needed -wl,-rpath,'/opt/pgsql14.1/lib',--enable-new-dtags -l/opt/pgsql14.1/lib -lpgcommon -lpgport -l/opt/pgsql14.1/lib -lpq -lpgcommon -lpgport -lz -lreadline -lpthread -lrt -ldl -lm -o pg_rman
[postgres@lyp pg_rman-master]$
[postgres@lyp pg_rman-master]$ make install
/usr/bin/mkdir -p '/opt/pgsql14.1/bin'
/usr/bin/install -c pg_rman '/opt/pgsql14.1/bin'
[postgres@lyp pg_rman-master]$
pg_rman使用
帮助说明
[postgres@lyp pg_rman-master]$ pg_rman --help
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
--recovery-target-action action the server should take once the recovery target is reached
--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
read the website for details. <http://github.com/ossc-db/pg_rman>
report bugs to <http://github.com/ossc-db/pg_rman/issues>.
[postgres@lyp pg_rman-master]$
初始化备份目录
[postgres@lyp ~]$ mkdir backup
[postgres@lyp ~]$ cd backup/
[postgres@lyp backup]$ pwd
/home/postgres/backup
[postgres@lyp backup]$ pg_rman init --backup-path=/home/postgres/backup
info: arclog_path is set to '/home/postgres/pgdata14/archive'
info: srvlog_path is set to '/home/postgres/pgdata14/log'
[postgres@lyp backup]$
备份恢复
全备
测试数据
postgres=# create database mydb1;
create database
postgres=# \c mydb1
you are now connected to database "mydb1" as user "postgres".
mydb1=# create table t1 (id1 int,name varchar(20));
create table
mydb1=# insert into t1 select n,'test'||n from generate_series(1,5) n;
insert 0 5
mydb1=# select * from t1;
id1 | name
----- -------
1 | test1
2 | test2
3 | test3
4 | test4
5 | test5
(5 rows)
mydb1=#
全备
[postgres@lyp backup]$ pg_rman backup --backup-mode=full --backup-path=/home/postgres/backup
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.
[postgres@lyp backup]$ pg_rman validate --backup-path=/home/postgres/backup
info: validate: "2022-02-17 22:36:02" backup and archive log files by crc
info: backup "2022-02-17 22:36:02" is valid
[postgres@lyp backup]$ pg_rman show --backup-path=/home/postgres/backup
=====================================================================
starttime endtime mode size tli status
=====================================================================
2022-02-17 22:36:02 2022-02-17 22:36:04 full 108mb 1 ok
[postgres@lyp backup]$
增量备份
测试数据
mydb1=# insert into t1 select n,'test'||n from generate_series(6,10) n;
insert 0 5
mydb1=# select * from t1;
id1 | name
----- --------
1 | test1
2 | test2
3 | test3
4 | test4
5 | test5
6 | test6
7 | test7
8 | test8
9 | test9
10 | test10
(10 rows)
mydb1=#
增量备份
[postgres@lyp backup]$ pg_rman backup --backup-mode=incremental --backup-path=/home/postgres/backup
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.
[postgres@lyp backup]$ pg_rman validate --backup-path=/home/postgres/backup
info: validate: "2022-02-17 22:36:37" backup and archive log files by crc
info: backup "2022-02-17 22:36:37" is valid
[postgres@lyp backup]$ pg_rman show --backup-path=/home/postgres/backup
=====================================================================
starttime endtime mode size tli status
=====================================================================
2022-02-17 22:36:37 2022-02-17 22:36:39 incr 33mb 1 ok
2022-02-17 22:36:02 2022-02-17 22:36:04 full 108mb 1 ok
[postgres@lyp backup]$
恢复
测试数据
mydb1=# \c postgres
you are now connected to database "postgres" as user "postgres".
postgres=# drop database mydb1;
drop database
postgres=# \l mydb1
list of databases
name | owner | encoding | collate | ctype | access privileges
------ ------- ---------- --------- ------- -------------------
(0 rows)
postgres=#
恢复全备
[postgres@lyp backup]$ pg_rman show --backup-path=/home/postgres/backup
=====================================================================
starttime endtime mode size tli status
=====================================================================
2022-02-17 22:36:37 2022-02-17 22:36:39 incr 33mb 1 ok
2022-02-17 22:36:02 2022-02-17 22:36:04 full 108mb 1 ok
[postgres@lyp backup]$ pg_rman restore --backup-path=/home/postgres/backup --recovery-target-time='2022-02-17 22:36:04'
error: postgresql server is running
hint: please stop postgresql server before executing restore.
[postgres@lyp backup]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@lyp backup]$ pg_rman restore --backup-path=/home/postgres/backup --recovery-target-time='2022-02-17 22:36:04'
info: the recovery target timeline id is not given
info: use timeline id of current database cluster 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: "2022-02-17 22:36:02"
info: copying online wal files and server log files
info: clearing restore destination
info: validate: "2022-02-17 22:36:02" backup and archive log files by size
info: backup "2022-02-17 22:36:02" is valid
info: restoring database files from the full mode backup "2022-02-17 22:36:02"
info: searching incremental backup to be restored
info: searching backup which contained archived wal files to be restored
info: backup "2022-02-17 22:36:02" is valid
info: restoring wal files from backup "2022-02-17 22:36:02"
info: backup "2022-02-17 22:36:37" is valid
info: restoring wal files from backup "2022-02-17 22:36:37"
info: restoring online wal files and server log files
info: create pg_rman_recovery.conf for recovery-related parameters.
info: remove an 'include' directive added by pg_rman in postgresql.conf if exists
info: append an 'include' directive in postgresql.conf for pg_rman_recovery.conf
info: generating recovery.signal
info: removing standby.signal if exists to restore as primary
info: restore complete
hint: recovery will start automatically when the postgresql server is started. after the recovery is done, we recommend to remove recovery-related parameters configured by pg_rman.
[postgres@lyp backup]$ pg_ctl start
waiting for server to start....2022-02-17 22:38:31.898 cst [120634] log: redirecting log output to logging collector process
2022-02-17 22:38:31.898 cst [120634] hint: future log output will appear in directory "log".
done
server started
[postgres@lyp backup]$
测试数据
[postgres@lyp ~]$ psql
psql (14.1)
type "help" for help.
postgres=# \l mydb1
list of databases
name | owner | encoding | collate | ctype | access privileges
------- ---------- ---------- ------------- ------------- -------------------
mydb1 | postgres | utf8 | en_us.utf-8 | en_us.utf-8 |
(1 row)
postgres=# \c mydb1
you are now connected to database "mydb1" as user "postgres".
mydb1=# \d
list of relations
schema | name | type | owner
-------- ------ ------- ----------
public | t1 | table | postgres
(1 row)
mydb1=#
mydb1=# select * from t1;
id1 | name
----- -------
1 | test1
2 | test2
3 | test3
4 | test4
5 | test5
(5 rows)
mydb1=#
savepoint cpt1
增量恢复
[postgres@lyp backup]$ pg_rman show --backup-path=/home/postgres/backup
=====================================================================
starttime endtime mode size tli status
=====================================================================
2022-02-17 21:53:35 2022-02-17 21:53:37 incr 33mb 1 ok
2022-02-17 21:52:47 2022-02-17 21:52:49 full 116mb 1 ok
[postgres@lyp backup]$ pg_rman restore --backup-path=/home/postgres/backup --recovery-target-time='2022-02-17 21:53:37'
error: postgresql server is running
hint: please stop postgresql server before executing restore.
[postgres@lyp backup]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres@lyp backup]$ pg_rman restore --backup-path=/home/postgres/backup --recovery-target-time='2022-02-17 21:53:37'
info: the recovery target timeline id is not given
info: use timeline id of current database cluster 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: "2022-02-17 21:52:47"
info: copying online wal files and server log files
info: clearing restore destination
info: validate: "2022-02-17 21:52:47" backup and archive log files by size
warning: backup file "/home/postgres/backup/20220217/215247/arclog/00000001000000000000006e" vanished
warning: backup "2022-02-17 21:52:47" is corrupted
info: restoring database files from the full mode backup "2022-02-17 21:52:47"
info: searching incremental backup to be restored
info: validate: "2022-02-17 21:53:35" backup and archive log files by size
warning: backup file "/home/postgres/backup/20220217/215335/arclog/000000010000000000000070" vanished
warning: backup "2022-02-17 21:53:35" is corrupted
info: restoring database files from the incremental mode backup "2022-02-17 21:53:35"
info: searching backup which contained archived wal files to be restored
info: restoring online wal files and server log files
info: create pg_rman_recovery.conf for recovery-related parameters.
info: remove an 'include' directive added by pg_rman in postgresql.conf if exists
info: append an 'include' directive in postgresql.conf for pg_rman_recovery.conf
info: generating recovery.signal
info: removing standby.signal if exists to restore as primary
info: restore complete
hint: recovery will start automatically when the postgresql server is started. after the recovery is done, we recommend to remove recovery-related parameters configured by pg_rman.
[postgres@lyp backup]$ pg_ctl start
waiting for server to start....2022-02-17 22:02:42.469 cst [117788] log: redirecting log output to logging collector process
2022-02-17 22:02:42.469 cst [117788] hint: future log output will appear in directory "log".
stopped waiting
pg_ctl: could not start server
examine the log output.
[postgres@lyp backup]$
日志
2022-02-17 22:40:45.889 cst [120857] log: starting postgresql 14.1 on x86_64-pc-linux-gnu, compiled by gcc (gcc) 4.8.5 20150623 (red hat 4.8.5-36), 64-bit
2022-02-17 22:40:45.889 cst [120857] log: listening on ipv4 address "0.0.0.0", port 5433
2022-02-17 22:40:45.889 cst [120857] log: listening on ipv6 address "::", port 5433
2022-02-17 22:40:45.892 cst [120857] log: listening on unix socket "/tmp/.s.pgsql.5433"
2022-02-17 22:40:45.895 cst [120859] log: database system was interrupted; last known up at 2022-02-17 22:36:37 cst
2022-02-17 22:40:45.904 cst [120859] log: starting point-in-time recovery to 2022-02-17 22:36:39 08
cp: cannot stat ‘/home/postgres/pgdata14/archive/000000010000000000000007’: no such file or directory
2022-02-17 22:40:45.910 cst [120859] log: invalid checkpoint record
2022-02-17 22:40:45.910 cst [120859] fatal: could not locate required checkpoint record
2022-02-17 22:40:45.910 cst [120859] hint: if you are restoring from a backup, touch "/home/postgres/pgdata14/recovery.signal" and add required recovery options.
if you are not restoring from a backup, try removing the file "/home/postgres/pgdata14/backup_label".
be careful: removing "/home/postgres/pgdata14/backup_label" will result in a corrupt cluster if restoring from a backup.
2022-02-17 22:40:45.910 cst [120857] log: startup process (pid 120859) exited with exit code 1
2022-02-17 22:40:45.910 cst [120857] log: aborting startup due to startup process failure
2022-02-17 22:40:45.912 cst [120857] log: database system is shut down
在 基于时间点之后,那么此时db与之前的备份已经不在同一时间线上。恢复默认只沿着基础备份建立时时间线恢复而不会切换到新的时间线,所以建议在恢复之后,立即对数据库做一个全库的备份。
rollback cpt1
再次全备
[postgres@lyp ~]$ pg_rman backup --backup-mode=full --backup-path=/home/postgres/backup
info: copying database files
error: query failed: error: recovery is in progress
hint: pg_walfile_name_offset() cannot be executed during recovery.
query was: select * from pg_walfile_name_offset(pg_start_backup($1, $2, $3))
[postgres@lyp ~]$
恢复之后, 数据库可能处于 read-only状态,此时可以用超户执行select pg_wal_replay_resume(); 或者在启动数据库实例前在postgresql.conf中添加recovery_target_action=‘promote’
postgres=# select pg_wal_replay_resume();
pg_wal_replay_resume
----------------------
(1 row)
postgres=# select * from t1;
id1 | name
----- -------
1 | test1
2 | test2
3 | test3
4 | test4
5 | test5
(5 rows)
postgres=# insert into t1 select n,'test'||n from generate_series(6,10) n;
insert 0 5
postgres=#
pg_rman.ini
pg_rman初始化之后会在备份目录中产生 pg_rman.ini 文件
[postgres@lyp backup]$ more pg_rman.ini
arclog_path='/home/postgres/pgdata14/archive'
srvlog_path='/home/postgres/pgdata14/log'
[postgres@lyp backup]$
可以编辑该文件并添加备份策略
keep_data_generations=4
keep_data_days=30
keep_arclog_days=35
keep_srvlog_days=180
keep_data_generations=4,保留4份全备数量
keep_data_days=30,数据保留30天,
keep_arclog_days=60,wal日志保留60天
keep_srvlog_days=180,log日志保留180天数
总结建议
- 在做备份操作时,建议使用参数
-c, --smooth-checkpoint do smooth checkpoint before backup (备份前做检查)
-z, --compress-data compress data backup with zlib (使用zlib压缩数据备份)
- 在做恢复操作时,建议使用参数
–hard-copy copying archivelog not symbolic link (copy 归档日志,而不是link软连接)
- 备份目录不能放在数据目录中
否则每备份都会将之前的备份再备份一遍,从而导致备份文件异常增大