Flashback script in Linux

Source: Internet
Author: User

A customer is concerned about the recovery of logical errors. The solution we recommend to him is to use the flashback Technology on the disaster recovery database. Below is a simple Linux script.

#! /Bin/bash

Export LOGIN_USER = test
Export LOGIN_PWD = test

######################################## # Function ###################################### #########

Flashscn ()
{
Echo-e "enter scn: \ c"
Read SCNNUM
STR1 = "flashback table $ OWNER. $ TABLE_NAME to scn $ SCNNUM ;"
Echo $ STR1
T1 = 'sqlplus-silent $ LOGIN_USER/$ LOGIN_USER <EOF
Set pagesize 0 feedback off verify off heading off echo off
Alter table $ OWNER. $ TABLE_NAME enable row movement;
$ STR1
Alter table $ OWNER. $ TABLE_NAME disable row movement;
EOF'
If [-z "$ T1"]; then
Echo "######"
Echo "flashback table $ TABLE_NAME OK! "
Else
Echo "######"
Echo "flashback tabel $ TABLE_NAME error :"
Echo $ T1 | awk-F "ORA-" '{print "ORA-" $ NF }'
Fi
}

Flashtime ()
{
Echo-e "enter time (example 20:34:21): \ c"
Read STIME
STR2 = "flashback table $ OWNER. $ TABLE_NAME to timestamp to_timestamp ('$ STIME', 'yyyy-mm-dd hh24: mi: ss ');"
Echo $ STR2
T2 = 'sqlplus-silent $ LOGIN_USER/$ LOGIN_USER <EOF
Set pagesize 0 feedback off verify off heading off echo off
Alter table $ OWNER. $ TABLE_NAME enable row movement;
$ STR2
Alter table $ OWNER. $ TABLE_NAME disable row movement;
EOF'
If [-z "$ T2"]; then
Echo "######"
Echo "flashback table $ TABLE_NAME OK! "
Else
Echo "######"
Echo "flashback tabel $ TABLE_NAME error :"
Echo $ T2 | awk-F "ORA-" '{print "ORA-" $ NF }'
Fi

}

######################################## #### Main start ################################## ############

Echo-e "enter flashback table owner: \ c"
Read OWNER
Echo-e "enter flashbackup table name: \ c"
Read TABLE_NAME
Echo-e "chose flashback type 1) time 2) scn 1 \ 2: \ c"
Read STYPE
Case $ STYPE in
1)
Flashtime
;;
2)
Flashscn
;;
*)
Echo "your enter is error, please enter 1 or 2 !!! "
Exit
;;
Esac

Recommended Editing:

Oracle 11g Flashback Data Archive (flash back Data archiving)

Oracle Flashback flash back Mechanism

Oracle Flashback database

Flashback table quick recovery of accidentally deleted data

Oracle backup recovery: Flashback flash back

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.