一.list命令列出控制文件,RMAN恢复目录中的备份信息。
list incarnation:汇总查询,备份文件多的话可以列出多个备份文件
list backup summary:概述可用的备份
list backup of database summary
list backup of archivelog all summary
list backup of tablespace users summary
list backup of datafile n,n,n summary
list backup by file
list backup of archivelog(controlfile,datebase,datafile,spfile,tablespace)
list expired backup
list copy of database(controlfile,tablespace users,datafile n,n,n,archivelog all,archivelog from scn 1000,archivelog until sequence 1000)
二.report用于判断当前数据库可恢复状态,以及以有的备份信息
report device(need,obsolete,schema,unrecoverable)
report need backup days=3(最近3天内没备份的数据)
report need backup redundancy=3(报告冗余次数小于3的数据文件)
report need backup recovery window of 2 days(需要2天的恢复归档日志的数据文件)
report need backup incremental=3(需要多少增量备份文件才能恢复的数据文件)
三.backup database tag='full_bak1' ---设置备份标志
backup database maxsetsize=100M tag='datafile1';---设置备份集大小
设置备份片大小:
run{
allocate channel c1 type disk maxpicecsize 1000M format
'/data/backup/full_0_%U_%T';
backup database tag='full_0';
release channel c1;
}在allocate中设置每个备份片的大小
也可以再configure中设置
configure channel device type disk maxpicecsize 100M;
configure channel device type diak clear;
四.备份集的保留策略
backup database keep forever;
backup database keep until time='sysdate+30';
backup database noexclude keep forever tag='test backup';---重写configure exclude命令
backup validate database;---检查数据库错误
跳过脱机,不可存取或只读文件
backup database skip readonly
backup database skip office
backup database skip inaccessile
backup database force;---强制备份
backup database not backed up;---只备份添加的新的数据文件
backup database not backed up since time='sysdate-2';---备份在限定时间内没有备份的文件
backup check logical database;---备份期间检查逻辑错误
backup validate check logical database;
backup database copies=2;---生成备份副本;
backup database device type disk include current controlfile;---备份控制文件
五:configure命令:
RMAN>show all;
SQL>select name,value from v$rman_configure;---查询RMAN中非默认设置
常用的configure选项
configure retention policy to recovery window of 7 days;---保持足够备份可以将数据库恢复到7天内的任意时刻,任何超过最近7天的数据备份将被标记为obsolete.
configure retention policy to redundancy 5;---保持可以恢复的最新的5份数据库,任何超过最新5份的备份都将被标记为redundancy.
configure retention policy clear(to none);---clear恢复默认策略,none策略失效
configure backup optimization on(off,clear);---RMAN备份优化打开,关闭,默认
configure default device type to disk;---磁盘
configure default device type to stb;---磁带
configure default device type clear;---默认
configure controlfile autobackup on ;
configure controlfile autobackup format for device type disk to '/data/backup/controlfile/controlfile_%F';
configure controlfile autobackup clear;
configure controlfile autobackup format for device type disk clear;
configure snapshot controlfile name to '/data/backup/snapcf/scontrolfile.snap';
configure snapshot controlfile name clear;
配置数据库设备备份类型的并行度:
configure channel device type disk format '/data/rmanbk_%U';
configure channel device type disk maxpiecesize 100M;
configure channel device type disk rate 1200K;
configure channel 1 device type disk format '/data/rmanbk_%U';
configure channel 1 device type disk maxpiecesize 100M;
生成备份副本:
configure datafile backup copies for device type disk/stb to 3;
configure archivelog backup copies for device type disk/stb to 3;
backup database device type disk/stb format '/disk1/backup/%U','/disk2/backup/%U','/disk3/backup/%U';---每次备份生成拷贝;
configure exclude for tablespace 'Users';---排除选项将指定的表空间不备份到备份集中
configure exclude clear;---恢复默认配置
六.格式:
%c:备份片的拷贝数
%d:数据库名称
%D:该月的第几天
%M:该年的第几月
%n:数据库名称,向右填补到最大8个字符
%u:一个代表8个字符的名称代表备份集与创建时间
%p:该备份集中的备份片号,从1开始
%U:一个唯一的文件名,代表%u_%p_%c
%s:备份集的号
%t:备份集的时间戳
%T:年月日格式(YYYYYMMDD)