RMAN> backup archivelog all delete input;
backup as compressed backupset backupset all;###备份片的再压缩
all, or until time 'sysdate -7'
RMAN> run {
backup archivelog all;
delete archivelog until time 'sysdate -1' like '/u01/archives/TEST/%';
delete archivelog until time 'sysdate -5' like '/u02/archives/TEST/%';
}
RMAN> run {
allocate channel c1 type 'sbt_tape';
set archivelog destination to '+FRA/TEST/ARCHIVELOG/2010_08_13';
restore archivelog
from time "to_date('13/08/2010-00:00:00','dd/mm/yyyy-hh24:mi:ss')"
until time "to_date('14/08/2010-00:00:00','dd/mm/yyyy-hh24:mi:ss')";
}
run {
allocate channel ch1 device type sbt parms 'SBT_LIBRARY=/home/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/home/oracle/OPC/opcConfig.ora)';
backup as compressed backupset database format '%d_DB_%U';
backup as compressed backupset archivelog all not backed up format '%d_ARCH_%U';
backup as compressed backupset current controlfile format '%d_CTRL_%U';
}
To confirm if the backup metadata is missing:
a. RMAN>list backup of database;
Look for the absence of level 0 backups for the present backup cycle
b. Query v$backup_datafile:
set lines 400
alter session set nls_date_format='dd-mon-rr hh24:mi:ss';
select recid, file#, to_char(creation_change#)crscn,
incremental_level lvl, to_char(incremental_change#) incrscn,
to_char(checkpoint_change#) ckpscn, checkpoint_time ckptime,
completion_time endtime, USED_CHANGE_TRACKING bct,
blocks_read read, block_size bsz, blocks wrtn
from v$backup_datafile
where file# > 0
and completion_time > '<date>';
Look for datafile backups where incremental_change#=creation_change
Sample output (edited):
recid File# crscn Lvl incr_change# ckp change#
------ ----- ------ ----- ------------- -----------------
61888 1 5 0 0 6066791848649
61975 1 5 1 6066791848649 6067000893725
62073 1 5 1 6066791848649 6067362932086
62179 1 5 1 6066791848649 6067740524868
62280 1 5 1 6066791848649 6068546799488
62393 1 5 1 5 6069467166501
For the backup with recid 62393, the backup was based on scn 5, which is the file creation scn.
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE= <new size>;
RMAN> backup device type 'sbt_tape' recovery area;
CROSSCHECK FOREIGN ARCHIVELOG ALL;
DELETE EXPIRED FOREIGN ARCHIVELOG ALL;
- You may also need to consider changing your backup retention policy . For Example :
RMAN> configure retention policy to recovery window of 5 days;
- When using Data Guard, consider changing your archivelog deletion policy.
- In case of 11g if Archivelog deletion policy is set to a higher value, conside changing it to a lower value.
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO SBT;
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO disk;
SELECT NAME,SPACE_LIMIT/1024/1024/1024 AS "SPACE_LIMIT(GB)",
SPACE_USED/1024/1024/1024 AS "SPACE_USED(GB)",
space_reclaimable /1024/1024/1024 AS "space_reclaimable (GB)",
number_of_files AS files
FROM V$RECOVERY_FILE_DEST;
SELECT * FROM V$FLASH_RECOVERY_AREA_USAGE WHERE file_TYPE = 'BACKUP PIECE';
DELETE NOPROMPT BACKUPSET COMPLETED BEFORE 'SYSDATE-&3';
delete noprompt force archivelog all completed before 'SYSDATE-7' backed up 1 times to device type sbt;
delete noprompt force archivelog all completed before 'SYSDATE-7' backed up 1 times to device type sbt;
delete noprompt force archivelog all backed up 1 times to device type sbt;
backup as compressed backupset archivelog all;
backup as compressed backupset database plus archivelog ;
Delete obsolete device type disk;
crosscheck archivelog all
##RAC 本地 /nfs----两个备份策略
delete noprompt expired backupset;
delete noprompt archivelog all completed before ‘sysdate-1’;
delete noprompt obsolete;
CONFIGURE RETENTION POLICY TO redundancy 2 device type 'SBT_TAPE';
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
backup COPIES 1 recovery area ; } ##########备份两份 不能两次
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
backup COPIES 1 RECOVERY FILES; }
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
BACKUP COPIES 2 BACKUPSET ALL; }
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
BACKUP COPIES 2 archivelog all; }
BACKUP DEVICE TYPE DISK AS BACKUPSET DATABASE PLUS ARCHIVELOG;
BACKUP
DEVICE TYPE sbt
BACKUPSET ALL; # copies backup sets on disk to tape
注:备份到sbt使用自动的通道,要求首先运行CONFIGURE DEVICE TYPE sbt命令。
可以使用BACKUP BACKUPSET来管理备份空间分配。以下示例将一个星期以前创建的备份集从磁盘备份到磁带,然后从磁盘上删除它们。
BACKUP
DEVICE TYPE sbt
BACKUPSET COMPLETED BEFORE ‘SYSDATE-7’
DELETE INPUT;
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
CROSSCHECK backup device type 'SBT_TAPE';
Delete obsolete device type SBT_TAPE;
delete expired backup device type SBT_TAPE;
}
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
Delete obsolete device type SBT_TAPE;}
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
restore datafile 3 ; }
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
delete backup tag TAG20231202T170516;
}
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
list backup summary; #####不需要带库里找 controlfile查看的
}
run {
allocate channel ch00 device type 'SBT_TAPE'
PARMS="SBT_LIBRARY=oracle.disksbt,
ENV=(BACKUP_DIR=/nfs)";
restore database until time 'sysdate -0.2';
recover database until time 'sysdate -0.2';
}
run {
allocate channel ch1 device type sbt parms 'SBT_LIBRARY=/home/oracle/OPC/lib/libopc.so,ENV=(OPC_PFILE=/home/oracle/OPC/opcConfig.ora)';
restore database preview until time "to_date('02-MAY-2020 19:30:00','DD-MON-YYYY HH24:MI:SS')";
}