shell写的数据库自动恢复脚本
时间:2010-09-26 来源:hero--008
echo "nohup sh ./recover.sh JX1 2010-09-26&">&2 exit 1;; esac ##check the hour is even or odd hour=`date +%k` flag=`(($(($hour%2))==0))&&echo 0 ||echo 1` while [ $flag -ne 1 ] do sleep 600s hour=`date +%k` flag=`(($(($hour%2))==0))&&echo 0 ||echo 1` done
##start recover the data ${SQLPLUS} ${ORACLE_USERNAME} << ! set feedback off set timing on spool ${PWD_DIR}/log/recover.log;
DECLARE v_running INT; v_stat_date date:=to_date('$recover_date','yyyy-mm-dd'); BEGIN SELECT COUNT ( * ) INTO v_running FROM user_scheduler_running_jobs WHERE job_name = 'SYN_DATA_WITH_PAYSYS';
IF v_running > 0 THEN GOTO recover; END IF;
jobs.syn_with_paysys_hourly;
DELETE FROM paysys_account_login_log WHERE login_date = v_stat_date;
COMMIT;
BEGIN -- Call the procedure calculate_account.calculate_online_time (v_stat_date); END;
BEGIN -- Call the procedure calculate_account.calculate_first_login_gway (v_stat_date); END;
BEGIN -- Call the procedure calculate_account.calculate_online_acnt_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_idcard.calculate_online_idcard_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_indep_ip.calculate_indep_ip_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_no_idcard.calculate_no_idcard_day (v_stat_date); END;
<<recover>> DELETE FROM paysys_account_login_log WHERE login_date = v_stat_date;
COMMIT;
BEGIN -- Call the procedure calculate_account.calculate_online_time (v_stat_date); END;
BEGIN -- Call the procedure calculate_account.calculate_first_login_gway (v_stat_date); END;
BEGIN -- Call the procedure calculate_account.calculate_online_acnt_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_idcard.calculate_online_idcard_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_indep_ip.calculate_indep_ip_day (v_stat_date); END;
BEGIN -- Call the procedure calculate_no_idcard.calculate_no_idcard_day (v_stat_date); END;
END;
spool off exit ! |