用户有两套Oracle9i双节点集群数据库,现在分别升级到Oracle10g和Oracle11g。由于新的存储还没到位,临时决定将大多数的存储都分配给了新系统。 原有生产系统只有300G的备份空间。而这两套生产系统数据库需要备份的文件大约60GB,可用的备份空间却只有300GB。在新存储到位之前需要修改一下备份策略,否则这区区300GB用着真是不放心。
现有生产数据库1:redundancy 2,数据库2:redundancy 3。
我的思路是:暂时将冗余全部修改为1,在每次备份结束后再强制删除obsolete文件。
下面看看我的环境
可用的备份空间
#df -g /databackup
Filesystem GB blocks Free %Used Iused %Iused Mounted on
/databackup 309.00 190.74 39% 43 1% /databackup
数据库1
要备份的文件大小为:23.54GB
SQL> select sum(bytes)/1024/1024/1024 from dba_segments;
SUM(BYTES)/1024/1024/1024
-------------------------
23.5430984
数据库2
要备份的文件大小为:37.07GB
SQL> select sum(bytes)/1024/1024/1024 from dba_segments;
SUM(BYTES)/1024/1024/1024
-------------------------
37.0738831
每天晚上22:00执行一次全备
crontab
0 22 * * * su - oracledb -c "/home/oracledb/backup.sh”
backup.sh脚本内容
rman target / nocatalog cmdfile=/home/oraprod/backup.cmd log=/databackup/db1_backup-`date +%Y%m%d`.log
backup.cmd脚本内容
1,冗余策略为1
2,分配维护通道 channel for maintenance, 介质为磁盘
3,删除被废弃的备份
run {
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
crosscheck backup;
crosscheck archivelog all;
delete force noprompt expired backup;
delete force noprompt expired archivelog all;
allocate channel ch01 device type disk connect sys/wrf496hgkgh@d7i.dtps_prod1;
allocate channel ch02 device type disk connect sys/wrf496hgkgh@DTPS_PROD;
backup
filesperset 5 format "/databackup/eam_full_%d_%s_%t_%p"
database include current controlfile;
sql 'alter system archive log current';
backup
archivelog all delete input filesperset 20 format "/databackup/eam_arch_%d_%s_%t_%p";
release channel ch02;
release channel ch01;
}
report obsolete device type disk;
crosscheck backup;
crosscheck archivelog all;
allocate channel for maintenance type disk;
delete force noprompt obsolete device type disk;
前面为执行全过程的屏幕输出节选
RMAN> @backup.cmd
RMAN> run {
2> CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
3> crosscheck backup;
4> crosscheck archivelog all;
5> delete force noprompt expired backup;
6> delete force noprompt expired archivelog all;
7> delete force noprompt obsolete;
8> allocate channel ch01 device type disk connect sys/dskh296fkjdh@prod1;
9> allocate channel ch02 device type disk connect sys/dskh296fkjdh@prod2;
10> backup
11> filesperset 15 format "/databackup/fmis_full_%d_%s_%t_%p"
12> database include current controlfile;
13> sql 'alter system archive log current';
14> backup
15> archivelog all delete input filesperset 30 format "/databackup/fmis_arch_%d_%s_%t_%p";
16> release channel ch02;
17> release channel ch01;
18> }
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;
new RMAN configuration parameters are successfully stored
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=144 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=51 devtype=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/databackup/bk_22893_857568521_1 recid=21765 stamp=857568523
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/databackup/bk_22894_857568546_1 recid=21766 stamp=857568551
…..略
Crosschecked 17 objects
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
validation succeeded for archived log
archive log filename=/ora_arch/arch1/1_51948.dbf recid=68949 stamp=857585448
validation succeeded for archived log
archive log filename=/ora_arch/arch1/1_51949.dbf recid=68950 stamp=857585602
…..略
Crosschecked 68 objects
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=51 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
using channel ORA_DISK_1
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
deleted archive log
archive log filename=/ora_arch/arch1/2_35622.dbf recid=68952 stamp=857585721
deleted archive log
archive log filename=/ora_arch/arch1/2_35623.dbf recid=68956 stamp=857590513
deleted archive log
…..略
Deleted 17 EXPIRED objects
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=51 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
using channel ORA_DISK_1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 21611 06-SEP-14
Backup Piece 21765 06-SEP-14 /databackup/bk_22893_857568521_1
Backup Set 21612 06-SEP-14
Backup Piece 21766 06-SEP-14 /databackup/bk_22894_857568546_1
Backup Set 21613 06-SEP-14
Backup Piece 21767 06-SEP-14 /databackup/bk_22895_857569000_1
Backup Set 21614 06-SEP-14
Backup Piece 21768 06-SEP-14 /databackup/bk_22896_857569061_1
Backup Set 21615 06-SEP-14
Backup Piece 21769 06-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-00
Backup Set 21616 06-SEP-14
Backup Piece 21770 06-SEP-14 /databackup/fmis_al_22899_857569568_1
Backup Set 21633 06-SEP-14
Backup Piece 21787 06-SEP-14 /databackup/fmis_al_22915_857569742_1
Backup Set 21634 06-SEP-14
Backup Piece 21788 06-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-01
Backup Set 21639 06-SEP-14
Backup Piece 21793 06-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-02
deleted backup piece
backup piece handle=/databackup/bk_22893_857568521_1 recid=21765 stamp=857568523
deleted backup piece
backup piece handle=/databackup/bk_22894_857568546_1 recid=21766 stamp=857568551
…..略
Deleted 9 objects
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ch01
channel ch01: sid=75 devtype=DISK
allocated channel: ch02
channel ch02: sid=36 devtype=DISK
Starting backup at 07-SEP-14
channel ch01: starting full datafile backupset
channel ch01: specifying datafile(s) in backupset
input datafile fno=00006 name=/dev/rrbs01.prd
input datafile fno=00014 name=/dev/rMEDIA04.prd
…..略
Finished backup at 07-SEP-14
Starting Control File Autobackup at 07-SEP-14
piece handle=/u01/prod/proddb/9.2.0/dbs/c-30397193-20140907-00 comment=NONE
Finished Control File Autobackup at 07-SEP-14
sql statement: alter system archive log current
Starting backup at 07-SEP-14
current log archived
channel ch01: starting archive log backupset
channel ch01: specifying archive log(s) in backup set
input archive log thread=1 sequence=51948 recid=68949 stamp=857585448
…..略
Finished backup at 07-SEP-14
Starting Control File Autobackup at 07-SEP-14
piece handle=/u01/prod/proddb/9.2.0/dbs/c-30397193-20140907-01 comment=NONE
Finished Control File Autobackup at 07-SEP-14
released channel: ch02
released channel: ch01
此处列出了可以删除的废弃备份
RMAN> report obsolete device type disk;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 21635 06-SEP-14
Backup Piece 21789 06-SEP-14 /databackup/bk_22917_857572554_1
Backup Set 21636 06-SEP-14
Backup Piece 21790 06-SEP-14 /databackup/bk_22918_857572579_1
Backup Set 21637 06-SEP-14
Backup Piece 21791 06-SEP-14 /databackup/bk_22919_857573044_1
Backup Set 21638 06-SEP-14
Backup Piece 21792 06-SEP-14 /databackup/bk_22920_857573095_1
Backup Set 21640 06-SEP-14
Backup Piece 21794 06-SEP-14 /databackup/al_22923_857584842_1
Backup Set 21641 06-SEP-14
Backup Piece 21795 06-SEP-14 /databackup/al_22922_857584817_1
Backup Set 21642 06-SEP-14
Backup Piece 21796 06-SEP-14 /databackup/al_22924_857584821_1
Backup Set 21643 06-SEP-14
Backup Piece 21797 06-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-03
Backup Set 21648 07-SEP-14
Backup Piece 21802 07-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140907-00
Backup Set 21650 07-SEP-14
Backup Piece 21804 07-SEP-14 /databackup/fmis_arch_PROD_22931_857657475_1
RMAN> crosscheck backup;
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: sid=144 devtype=SBT_TAPE
channel ORA_SBT_TAPE_1: Veritas NetBackup for Oracle - Release 6.5 (2007072323)
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=51 devtype=DISK
crosschecked backup piece: found to be 'AVAILABLE'
backup piece handle=/databackup/bk_22917_857572554_1 recid=21789 stamp=857572555
crosschecked backup piece: found to be 'AVAILABLE'
…..略
Crosschecked 17 objects
RMAN> crosscheck archivelog all;
released channel: ORA_SBT_TAPE_1
released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
specification does not match any archive log in the recovery catalog
RMAN> allocate channel for maintenance type disk;
released channel: ORA_DISK_1
allocated channel: ORA_MAINT_DISK_1
channel ORA_MAINT_DISK_1: sid=144 devtype=DISK
开始删除废弃的备份
RMAN> delete force noprompt obsolete device type disk;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Deleting the following obsolete backups and copies:
Type Key Completion Time Filename/Handle
-------------------- ------ ------------------ --------------------
Backup Set 21635 06-SEP-14
Backup Piece 21789 06-SEP-14 /databackup/bk_22917_857572554_1
Backup Set 21636 06-SEP-14
Backup Piece 21790 06-SEP-14 /databackup/bk_22918_857572579_1
Backup Set 21637 06-SEP-14
Backup Piece 21791 06-SEP-14 /databackup/bk_22919_857573044_1
Backup Set 21638 06-SEP-14
Backup Piece 21792 06-SEP-14 /databackup/bk_22920_857573095_1
Backup Set 21640 06-SEP-14
Backup Piece 21794 06-SEP-14 /databackup/al_22923_857584842_1
Backup Set 21641 06-SEP-14
Backup Piece 21795 06-SEP-14 /databackup/al_22922_857584817_1
Backup Set 21642 06-SEP-14
Backup Piece 21796 06-SEP-14 /databackup/al_22924_857584821_1
Backup Set 21643 06-SEP-14
Backup Piece 21797 06-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-03
Backup Set 21648 07-SEP-14
Backup Piece 21802 07-SEP-14 /u01/prod/proddb/9.2.0/dbs/c-30397193-20140907-00
Backup Set 21650 07-SEP-14
Backup Piece 21804 07-SEP-14 /databackup/fmis_arch_PROD_22931_857657475_1
deleted backup piece
backup piece handle=/databackup/bk_22917_857572554_1 recid=21789 stamp=857572555
deleted backup piece
backup piece handle=/databackup/bk_22918_857572579_1 recid=21790 stamp=857572584
deleted backup piece
backup piece handle=/databackup/bk_22919_857573044_1 recid=21791 stamp=857573051
deleted backup piece
backup piece handle=/databackup/bk_22920_857573095_1 recid=21792 stamp=857573101
deleted backup piece
backup piece handle=/databackup/al_22923_857584842_1 recid=21794 stamp=857584843
deleted backup piece
backup piece handle=/databackup/al_22922_857584817_1 recid=21795 stamp=857584818
deleted backup piece
backup piece handle=/databackup/al_22924_857584821_1 recid=21796 stamp=857584822
deleted backup piece
backup piece handle=/u01/prod/proddb/9.2.0/dbs/c-30397193-20140906-03 recid=21797 stamp=857584827
deleted backup piece
backup piece handle=/u01/prod/proddb/9.2.0/dbs/c-30397193-20140907-00 recid=21802 stamp=857657450
deleted backup piece
backup piece handle=/databackup/fmis_arch_PROD_22931_857657475_1 recid=21804 stamp=857657476
Deleted 10 objects
RMAN> **end-of-file**
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29762980/viewspace-1362004/
,如需转载,请注明出处,否则将追究法律责任。