postgresql 物理备份 pg_rman 之四 delete purge

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/ctypyb2002/article/details/84771734

os: centos 7.4
postgresql: 9.6.9
pg_rman: REL9_6_STABLE

pg_rman delete

若果提示不能删除,请执行查看输出信息。一般情况下是因为有依赖关系。除非dba再三确认,可以指定 -f 参数。

$ pg_rman show detail
======================================================================================================================
 StartTime           EndTime              Mode    Data  ArcLog  SrvLog   Total  Compressed  CurTLI  ParentTLI  Status 
======================================================================================================================
2018-12-03 15:45:06  2018-12-03 15:45:12  ARCH    ----   234MB    ----    26MB        true       1          0  OK
2018-12-03 13:07:24  2018-12-03 13:07:29  INCR  3186kB    67MB    ----  8138kB        true       1          0  OK
2018-12-03 13:04:57  2018-12-03 13:05:18  FULL   406MB    67MB    28kB   443MB       false       1          0  OK
2018-12-03 13:01:14  2018-12-03 13:01:20  INCR  2932kB   100MB    ----    11MB        true       1          0  OK
2018-12-03 12:16:05  2018-12-03 12:16:10  INCR  3203kB    67MB    ----  8083kB        true       1          0  OK
2018-12-03 11:53:39  2018-12-03 11:54:00  FULL   405MB    83MB  2231kB   461MB       false       1          0  OK

$ pg_rman delete '2018-12-03 11:53:39'
WARNING: cannot delete backup with start time "2018-12-03 11:53:39"
DETAIL: This is the latest full backup necessary for successful recovery.

另外 pg_rman delete 其实是删除 可以恢复到指定时间的备份之外的无用备份。描述有点绕

$ pg_rman delete '2018-12-03 13:06:39'

WARNING: cannot delete backup with start time "2018-12-03 13:04:57"
DETAIL: This is the latest full backup necessary for successful recovery.
INFO: delete the backup with start time: "2018-12-03 13:01:14"
INFO: delete the backup with start time: "2018-12-03 12:16:05"
INFO: delete the backup with start time: "2018-12-03 11:53:39"


$ pg_rman show detail
======================================================================================================================
 StartTime           EndTime              Mode    Data  ArcLog  SrvLog   Total  Compressed  CurTLI  ParentTLI  Status 
======================================================================================================================
2018-12-03 15:45:06  2018-12-03 15:45:12  ARCH    ----   234MB    ----    26MB        true       1          0  OK
2018-12-03 13:07:24  2018-12-03 13:07:29  INCR  3186kB    67MB    ----  8138kB        true       1          0  OK
2018-12-03 13:04:57  2018-12-03 13:05:18  FULL   406MB    67MB    28kB   443MB       false       1          0  OK

对应的物理文件也已经被删除,只留下一些参数文件

$ tree 115339
115339
├── backup.ini
├── file_arclog.txt
├── file_database.txt
├── file_srvlog.txt
└── mkdirs.sh

0 directories, 5 files
-bash-4.2$ tree 121605
121605
├── backup.ini
├── file_arclog.txt
├── file_database.txt
└── mkdirs.sh

0 directories, 4 files
-bash-4.2$ tree 130114
130114
├── backup.ini
├── file_arclog.txt
├── file_database.txt
└── mkdirs.sh

0 directories, 4 files

pg_rman purge

$ pg_rman purge

INFO: DELETED backup "2018-12-03 13:01:14" is purged
INFO: DELETED backup "2018-12-03 12:16:05" is purged
INFO: DELETED backup "2018-12-03 11:53:39" is purged

$ ls -l
total 0
drwx------ 5 postgres postgres 156 Dec  3 13:05 130457
drwx------ 5 postgres postgres 133 Dec  3 13:07 130724
drwx------ 5 postgres postgres  91 Dec  3 15:45 154506
drwx------ 5 postgres postgres 156 Dec  3 16:05 160519

对应备份的所有信息都被清楚了。

参考:
https://github.com/ossc-db/pg_rman/tree/master
http://ossc-db.github.io/pg_rman/index.html
https://travis-ci.org/ossc-db/pg_rman

猜你喜欢

转载自blog.csdn.net/ctypyb2002/article/details/84771734