共计 2871 个字符,预计需要花费 8 分钟才能阅读完成。
一、基础知识
大家对 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.
更多 Oracle 相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-11/137685.htm