RMAN备份常用例子

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 03:55 点击:

rman备份命令

1:to back the controlfile using rman
备份控制文件
run{
allocate channel dev1 type disk format 'c:backup%U';
backup current controlfile;
}
2:to check the backup of controlfile using rman:
检查备份的控制文件
list backup of controlfile;
3:to recover using backup controlfile(startup nomount)
恢复控制文件
run {
allocate channel dev1 type disk;
restore controlfile;
alter database mount;
restore database;
recover database;
sql "ALTER DATABASE OPEN RESETLOGS"
}
4:backup all datafile and controlfile using rman:
备份所有的数据文件和控制文件
run {
allocate channel dev1 type disk;
backup full tag = 'full backup' database include current controlfile format = 'c:backupdb_t%t_s%s_p%p';
release channel dev1;
}
5:check all backup of datafiles using rman:
检查所有的数据文件和控制文件
list backupset;
6:to restore because of missing file(first mount the database and run RMAN)
因文件丢失而修复
run {
allocate channel dev1 type disk;
restore database;
recover database;
}
7:restore until time
恢复到某个时间点
The 'SET UNTIL TIME' must match with the variable NLS_DATE_FORMAT.
Prior logging on RMAN set the NLS_DATE_FORMAT in the desired format.
For example:
If unix ===> export NLS_DATE_FORMAT='YYYY-MM-DD:HH24:MI:SS';
If on windows nt ===> set this vaiable in the registery.
run {
set until time 'May 1 2000 08:00:00';
allocate channel dev1 type disk;
shutdown abort;
startup nomount;
restore controlfile;
alter database mount;
restore database;
recover database;
sql 'alter database open resetlogs';
}
8:to purge obsolete backups:
清除旧的备份
report obsolete redundancy 3 device type disk; #REPORTS ANY BACKUP WITH MORE THAN 3 COPIES
report obsolete orphan; #USE THIS REPORT TO FILL IN THE XXXXX BELOW
run {
allocate channel for maintenance type disk;
allocate channel for delete type disk;
change backuppiece 'C:BACKUPxxxx' delete;
release channel;
run {
allocate channel for maintenance type disk;
allocate channel for delete type disk;
change datafilecopy 'C:BACKUPxxxx' delete;
release channel;
9:to backup all archive logs
备份所有的归档日志
run{
allocate channel dev1 type disk format 'c:backup%U';
backup archivelog all;
}
10:to remove all archive log files alter backup update to this line
backup archivelog all delete input;
11:skip an archive log file that can not be read or manualy deleted update to this line
backup archivelog skip inaccessible /inaccessible不可存取
12:to remove one archive log that you manualy deleted and now get an rman-6089<=8.0
allocate channel for delete type disk; or 'SBT_TAPE';
change archivelog 'path/filename' delete;
and/or
resync catalog;
13:to remove one archive log that you manualy deleted and now get an rman-6089<=8.1
allocate channel for maintenance type ....'
change archivelog uncatalog
一个实用脚本,包括备份RAC数据库与归档日志的shell脚本
[oracle@db worksh]$ more rmanback.sh
#!/bin/sh
#set env
export ORACLE_HOME=/opt/oracle/product/9.2
export ORACLE_SID=ebiz
export NLS_LANG="AMERICAN_AMERICA.zhs16gbk"
export PATH=$PATH:$ORACLE_HOME/bin:/sbin:/usr/sbin
echo "-----------------------------start-----------------------------";date
#backup start
$ORACLE_HOME/bin/rman <<EOF
connect target
delete noprompt obsolete;
backup database include current controlfile format '/rmanback

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • Table函数使用简介
    • Oracle数据库Constraint约束的常用操作及异常处理
    • Bulk Collect性能分析(zz)
    • export/import的使用
    • OCP043第十五讲 Database Security
    • ORACLE10gr2数据导入MySQL方案
    • oracle 让sys用户可以使用isqlplus
    • 在oracle数据库下使用iSQL*Plus DBA访问数据库
    • Oracle行列转换小结
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1