Recommendation One:
With task scheduling, batch files, and the EXP export capabilities of Oracle, Oracle backup files can be automatically generated based on dates, greatly facilitating Oracle data backup. :
1, set up batch processing file backup.bat\.
Exp System/manager file=d:\backup\oracle\oracle%date:~0,10%.dmp Owner=system log=d:\backup\oracle\oracle%date:~ 0,10%.log
The Oracle2006-01-09.dmp file will be generated
Exp System/manager file=d:\backup\oracle\oracle%date:~11,3%.dmp Owner=system log=d:\backup\oracle\oracle%date:~ 11,3%.log
The Oracle Monday. dmp file is generated, and a backup file is kept in a weekly loop, with a total of 7 backup file loops
2. Add a task plan
Use the Task Scheduler Wizard to set the time frequency for automatic task execution based on the backup policy (for example, 0 o'clock per day) to perform D:\oracle\backup.bat
3. The backup and log files, such as "Oracle2005-08-31.dmp and Oracle2005-08-31.log", will be generated in the directory every day.
Description
1, the value of%date% in different system, language version may not be the same, the control panel inside the settings of the regional options will also change the value of%date%. Please test the return value of Echo%date% on the command line first. %date:~4,10% is the return date function, after which the first argument is the starting position to intercept (starting at 0), the second parameter is the length to intercept, and if not, the parameter can be modified as appropriate.
2, if the need for accurate time as a filename, please use the%time% function, the parameters ibid.
Recommendation two:
@echo off
Set filename=e:\data_bak\%date:~8,2% Day
Exp userid=user/[email protected] file=%filename%.dmp owner=user indexes=y grants=y constraints=y Compress=y Log=%filename%.log
RAR a%filename%.rar%filename%.*
Del%filename%.dmp
Del%filename%.log
Put the scheduled tasks inside,
The file name is named with the day part of the date
Call RAR after backup to compress
This will save one months of historical data.
Note: You need to copy the Rar.exe from the program Files/winrar directory to the system system32 directory
If you are naming a week, you need to change the set filename=e:\data_bak\%date:~8,2% to
Set filename=e:\data_bak\%date:~0,3%
Recommendation three:
The following is an automated backup batch file content for Oracle, which is implemented with task scheduling
@ECHO OFF
SET backpath=d:\
ECHO ready to back up the database
REM 7 day One cycle
IF EXIST%backpath%\one GOTO One
IF EXIST%backpath%\two GOTO
IF EXIST%backpath%\three GOTO Three
IF EXIST%backpath%\four GOTO Four
IF EXIST%backpath%\five GOTO FIVE
IF EXIST%backpath%\six GOTO SIX
IF EXIST%backpath%\seven GOTO SEVEN
ECHO E >%backpath%\one
: one
SET Backpath_full=%backpath%\one
REN%backpath%\one
GOTO back
: both
SET Backpath_full=%backpath%\two
REN%backpath%\two Three
GOTO back
: Three
SET Backpath_full=%backpath%\three
REN%backpath%\three Four
GOTO back
: Four
SET Backpath_full=%backpath%\four
REN%backpath%\four FIVE
GOTO back
: FIVE
SET backpath_full=%backpath%\five
REN%backpath%\five SIX
GOTO back
: SIX
SET Backpath_full=%backpath%\six
REN%backpath%\six SEVEN
GOTO back
: SEVEN
SET Backpath_full=%backpath%\seven
REN%backpath%\seven One
GOTO back
: Back
EXP testuser/test file=%backpath_full%. DMP
SET backpath=
SET backpath_full=
EXIT
Recommendation IV:
RMAN target=rman/[email protected] < C:\RMAN. TXT
Recommendation Five:
Edit the cmd command in the text. Then save it as a bat file. When you define a task schedule in Windows, you
It can be executed automatically.
Cases:
Edit a text file
Del c:\exp\*.dmp
Exp userid=cw/[email protected] file= ' c:\exp\*.dmp ' tables= (student)
Save As BAT file
Recommendation Six:
Write a simple batch file backup recovery:
Backup:
@echo off does not display the command line
Echo begins to back up the table ..... Printing information
D:dos Switch to D: Disk
CD Oracle\ora92\bin switch to CD Oracle\ora92\bin directory
EXP username/Password @ database file=d:\config_bak.dmp tables= (table1,table2) Backup table one table two to D:\config_bak.dmp
echo Backup Complete!
Recovery:
@echo off
Echo begins to recover the table .....
D:
CD Oracle\ora92\bin
IMP username/password @ database file=d:\config_bak.dmp tables= (table1,table2) ignore=y
Sqlplus/nolog @oraStartup. Sql>>orastartup.log calling the SQL file
Pause after execution of the SQL file, see information
echo Recovery is complete!
Writing Orastartup.sql
Conn username/password @ database as Sysdba
SELECT * FROM table1;
Quit
Execution environment: can be executed in SQLPLUS.EXE or DOS (command line),
DOS can be executed due to the installation of directory \ora81\bin in Oracle 8i is set to the global path,
This directory has EXP.EXE and IMP.EXE files that are used to perform import and export.
Oracle is written in Java, I want to SQLPLUS.EXE, EXP. EXE, IMP. EXE these two files are packaged after the class file.
SQLPLUS. EXE calls EXP.EXE, IMP. EXE They wrap the class, complete the import and export function.
The following is an example of importing and exporting, and seeing an instance of import and export is basically done, because importing and exporting is simple.
Data export:
1 full export of database test, user Name System Password Manager exported to D:\daochu.dmp
Exp system/[email protected] file=d:\daochu.dmp full=y
2 Exporting the system user in the database to the SYS user's table
Exp system/[email protected] file=d:\daochu.dmp owner= (system,sys)
3 Exporting Tables Table1, table2 in the database
Exp system/[email protected] file=d:\daochu.dmp tables= (table1,table2)
4 Export the field filed1 in table table1 in the database with data beginning with "00"
Exp system/[email protected] file=d:\daochu.dmp tables= (table1) query=\ "where filed1 like ' 0% ' \"
The above is a common export, for compression I do not care, with WinZip to the DMP file can be very good compression.
But add compress=y to the upper order.
Import of data
1 Import the data from the D:\DAOCHU.DMP into the test database.
Imp system/[email protected] file=d:\daochu.dmp
There may be a problem, because some tables already exist, and then it is an error, and the table is not imported.
Add Ignore=y to the back.
2 Import the table table1 in D:\daochu.dmp
Imp system/[email protected] file=d:\daochu.dmp tables= (table1)
Import
Basically, the above import and export is enough. In a few cases I have completely removed the table and then imported
Simple Oracle Backup Recovery batch File