码迷,mamicode.com
首页 > 数据库 > 详细

PostgreSQL备份恢复-pg_rman

时间:2020-06-21 00:43:29      阅读:99      评论:0      收藏:0      [点我收藏+]

标签:pg1   srv   ase   arc   ali   sql   validate   inf   比较   

数据库及pg_rman版本

postgresql:(PostgreSQL) 12.3

pg_rman:pg_rman-1.3.9-pg12.tar.gz

编辑环境变量

$ id
uid=5432(postgres) gid=5432(postgres) groups=5432(postgres)
$ pwd
/home/postgres

$vi .bash_profile
export PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin

$ pg_rman init -B /data/db_backup
INFO: ARCLOG_PATH is set to ‘/data/pgsql_5432/archive/‘
INFO: SRVLOG_PATH is set to ‘/data/pgsql_5432/logs/‘
全量压缩备份
$ pg_rman backup -b full -U postgres -Z -h 127.0.0.1 -p 5432
Password for user postgres: 

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.

增量压缩备份

pg_rman backup -b incremental -U postgres -Z -h 127.0.0.1 -p 5432

查看备份

pg_rman show

备份校验(每次备份完,必须要做一次校验,否则备份集不可用来恢复,增量备份时也不会用它来做增量比较)

pg_rman validate

还原备份

pg_rman restore --recovery-target-time “2020-06-11 23:00:00”;

 

PostgreSQL备份恢复-pg_rman

标签:pg1   srv   ase   arc   ali   sql   validate   inf   比较   

原文地址:https://www.cnblogs.com/elontian/p/13170864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!