大家对RMAN我想都有不少的了解,此处只想对增量备份进行一下学习与实践,也是因为工作中确实有这样的需求存在。增量备份分为两种:Differential 差异,Cumulative 累积。如果不指明增量备份参数,默认的增量备份为Differential差异。常规备份方案:1周1次0级备份,其余为差异增量1级备份。或者1周1次0级备份,后两天为差异1级备份,第三天累积1级备份,后面0级备份前再次差异1级备份。总而言知,你了解了备份原理,后面策略就你自己定了。I believe you that you can choose correct policy.
(1)Differential Incremental Backups
差异增量备份,就是备份最近1次增量备份(差异或者累积)或者0级全备份后的所有变化的数据块。
(2)Cumulative Incremental Backups
累积增量备份,就是备份最近0级备份后的所有变化的数据块,所以占用空间是比较多些。
二、实验备份
(1)0级备份scripts:
#!/bin/bash
source /home/Oracle/.bash_profile
# Local variable
day=`date +%Y%m%d`
bk_dir=/rmanbackup/rman/TEST${day}
# Create backup directory
mkdir -p $bk_dir
# Incremental level 0 backup
rman target / log=$bk_dir/${day}.log <<EOF
RUN {
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$bk_dir/%F';
ALLOCATE CHANNEL ch01 TYPE DISK MAXPIECESIZE=10G;
ALLOCATE CHANNEL ch02 TYPE DISK MAXPIECESIZE=10G;
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 0 DATABASE SKIP INACCESSIBLE FILESPERSET 10 FORMAT '$bk_dir/db_%T_%U.bak' PLUS ARCHIVELOG FILESPERSET 20 DELETE ALL INPUT FORMAT '$bk_dir/arch_%T_%U.bak';
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT OBSOLETE;
EOF
(2)1级差异增量备份scripst:
点击(此处)折叠或打开
#!/bin/bash
source /home/oracle/.bash_profile
# Local variable
day=`date +%Y%m%d`
bk_dir=/rmanbackup/rman/TEST${day}
# Create backup directory
mkdir -p bk_dir
# Differential Incremental level 1 backup
rman target / log=$bk_dir/${day}.log <<EOF
RUN {
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$bk_dir/%F';
ALLOCATE CHANNEL ch01 TYPE DISK MAXPIECESIZE=10G;
ALLOCATE CHANNEL ch02 TYPE DISK MAXPIECESIZE=10G;
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 DATABASE SKIP INACCESSIBLE FILESPERSET 10 FORMAT '$bk_dir/db_%T_%U.bak' PLUS ARCHIVELOG FILESPERSET 20 FORMAT '$bk_dir/arch_%T_%U.bak' DELETE ALL INPUT;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT OBSOLETE;
EOF
(3)1级累积增量备份scripst:
#!/bin/bash
source /home/oracle/.bash_profile
# Local variable
day=`date +%Y%m%d`
bk_dir=/rmanbackup/rman/TEST${day}
# Create backup directory
mkdir -p bk_dir
# Cumulative Incremental level 1 backup
rman target / log=$bk_dir/${day}.log <<EOF
RUN {
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '$bk_dir/%F';
ALLOCATE CHANNEL ch01 TYPE DISK MAXPIECESIZE=10G;
ALLOCATE CHANNEL ch02 TYPE DISK MAXPIECESIZE=10G;
BACKUP AS COMPRESSED BACKUPSET INCREMENTAL LEVEL 1 CUMULATIVE DATABASE SKIP INACCESSIBLE FILESPERSET 10 FORMAT '$bk_dir/db_%T_%U.bak' PLUS ARCHIVELOG FILESPERSET 20 FORMAT '$bk_dir/arch_%T_%U.bak' DELETE ALL INPUT;
RELEASE CHANNEL ch01;
RELEASE CHANNEL ch02;
}
ALLOCATE CHANNEL FOR MAINTENANCE DEVICE TYPE DISK;
CROSSCHECK BACKUPSET;
DELETE NOPROMPT OBSOLETE;
EOF
三、总结
此次对增量备份进行了学习与实践,在实验过程中发现Differential Incremental 与 Cumulative Incremental的备份信息在rman中用list显示时都是1,无法分别。DBA们的看家本领,有备无患,所以每位DBA的小伙伴要学习好备份与恢复。Where there’s a will, there’s a way. Fighting Sam.