完整备份
run {
#### 分配备份通道
allocate channel c1 type disk;
allocate channel c2 type disk;
# 备份数据文件
backup as compressed backupset database format 'D:\rmanbackup\db_%T_%U.bak';
# 备份数据文件完成后,关闭所有通道
release channel c1;
release channel c2;
# 重新分配通道备份控制文件和 SPFILE
allocate channel c3 type disk;
backup current controlfile format 'D:\rmanbackup\ctl_%T_%U.bak';
backup spfile format 'D:\rmanbackup\sp_%T_%U.bak';
# 释放备份控制文件和 SPFILE 的通道,然后重新分配通道用于 crosscheck 和 delete 操作
release channel c3;
# 分配新通道 c4 用于 crosscheck 和 delete 操作
allocate channel c4 type disk;
crosscheck archivelog all;
crosscheck backup;
# 备份所有归档日志文件
backup as compressed backupset archivelog all format 'D:\rmanbackup\arch_%T_%U.bak';
# 清理指定时间之前的归档日志和备份文件
delete noprompt archivelog all completed before 'sysdate-7';
delete noprompt backup completed before 'sysdate-1';
release channel c4;
}
增量备份
run {
# 分配备份通道
allocate channel c1 type disk;
allocate channel c2 type disk;
# 备份数据文件
backup incremental level 1 as compressed backupset database format 'D:\rmanbackup\inc1_db_%T_%U.bak';
# 备份数据文件完成后,关闭所有通道
release channel c1;
release channel c2;
# 重新分配通道备份控制文件和 SPFILE
allocate channel c3 type disk;
backup current controlfile format 'D:\rmanbackup\ctl_%T_%U.bak';
backup spfile format 'D:\rmanbackup\sp_%T_%U.bak';
# 释放备份控制文件和 SPFILE 的通道,然后重新分配通道用于 crosscheck 和 delete 操作
release channel c3;
# 分配新通道 c4 用于 crosscheck 和 delete 操作
allocate channel c4 type disk;
crosscheck archivelog all;
crosscheck backup;
# 备份所有归档日志文件
backup as compressed backupset archivelog all format 'D:\rmanbackup\arch_%T_%U.bak';
# 清理指定时间之前的归档日志和备份文件
delete noprompt archivelog all completed before 'sysdate-7';
delete noprompt backup completed before 'sysdate-1';
release channel c4;
}
差异备份
run {
# 分配备份通道
allocate channel c1 type disk;
allocate channel c2 type disk;
# 备份数据文件
backup incremental level 1 differential as compressed backupset database format 'D:\rmanbackup\diff_db_%T_%U.bak';
# 备份数据文件完成后,关闭所有通道
release channel c1;
release channel c2;
# 重新分配通道备份控制文件和 SPFILE
allocate channel c3 type disk;
backup current controlfile format 'D:\rmanbackup\ctl_%T_%U.bak';
backup spfile format 'D:\rmanbackup\sp_%T_%U.bak';
# 释放备份控制文件和 SPFILE 的通道,然后重新分配通道用于 crosscheck 和 delete 操作
release channel c3;
# 分配新通道 c4 用于 crosscheck 和 delete 操作
allocate channel c4 type disk;
crosscheck archivelog all;
crosscheck backup;
# 备份所有归档日志文件
backup as compressed backupset archivelog all format 'D:\rmanbackup\arch_%T_%U.bak';
# 清理指定时间之前的归档日志和备份文件
delete noprompt archivelog all completed before 'sysdate-7';
delete noprompt backup completed before 'sysdate-1';
release channel c4;
}
评论 (0)