#./autorestore 2017-12-11 6:00:00 #root调用方式
dt=$1
DATE=${dt//-/}
time=$2
point=$1" "$2
su - oracle -c "sqlplus / as sysdba
@/home/oracle/shutdown.sql"
su - grid -c "asmcmd rm +data/oemsdb/datafile/*.*"
su - grid -c "asmcmd rm +data/oemsdb/control*.*"
su - oracle -c "rman target / << EOF
startup nomount;
restore controlfile from
'/ddbak/rman_bak/$DATE/c-114679065-$DATE-00';
alter database mount;
catalog start with '/ddbak/rman_bak/$DATE/';
yes
run{
ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH3 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH4 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH5 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH6 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH7 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH8 DEVICE TYPE DISK;
restore database;
RELEASE CHANNEL CH1;
RELEASE CHANNEL CH2;
RELEASE CHANNEL CH3;
RELEASE CHANNEL CH4;
RELEASE CHANNEL CH5;
RELEASE CHANNEL CH6;
RELEASE CHANNEL CH7;
RELEASE CHANNEL CH8;
}
run
{
crosscheck archivelog all;
delete noprompt expired archivelog all;
crosscheck backup;
delete noprompt expired backup;
recover database until time '$point';
}
EOF
"
su - oracle -c "sqlplus / as sysdba
@/home/oracle/readonly.sql"