Today, due to the working relationship, we need to design a backup solution for ORACLE. Because the database is large, it is not suitable
The daily backup is saved, So we designed the overwriting backup for 7 files every week. The specific steps are as follows: www.2cto.com 1. Create a SHELL execution script oracle_backup.sh [root @ czjie ~] # Vi/data/oracle/orabak/oracle_backup.sh :#! /Bin/bash
Export ORACLE_BASE =/opt/app/oracle
Export ORACLE_HOME = $ ORACLE_BASE/product/10.2.0/db_1
Export ORACLE_SID = orcl
Export PATH = $ ORACLE_HOME/bin: $ PATH
Export NLS_LANG = AMERICAN_AMERICA.ZHS16GBK # generate the backup file name, last digit
Corresponding to the word (0-6) (Sunday-Saturday)
A = czjie_bak_week $ (date + % w)
Echo $
Exp czjie/czjie_2012 file =/data/oracle/orabak/$. dmp log =/data/oracle/orabak/$. log www.2cto.com Note: export NLS_LANG = AMERICAN_AMERICA.ZHS16GBK. If this line does not exist
When the environment variable of the exp tool is inconsistent with the NLS_CHARCATERSET in nls lang
EXP-00091 Exporting questionable statistics, if you do not know how to get the NLS_CHARCATERSET,
See my article: EXP-00091 Exporting questionable statisticsa = czjie_bak_week $ (date + % w) gets the week number, always in the order of Sunday 0
You can use the $ (date + % w-d "1 days ago") method to adjust the number of days during the test until 6 of Saturday. 2. grant the SHELL script executable permission and the owner of the user [root @ czjie ~] # Cd/data/oracle/orabak
[Root @ czjie orabak] # chmod 700 backup. sh
[Root @ czjie orabak] # chown oracle backup. sh 3. Ensure that the backup file directory belongs to the oracle user [root @ czjie ~] # Chown-R oracle. oinstall/data/oracle/orabak/4. Create a crontab for oracle users [root @ czjie ~] # Crontab-u oracle-e # Add the following content: 0 6 ***/data/oracle/orabak/oracle_backup.sh Note: 0 6 *** indicates scheduling once every morning, the execution statement is followed. It can be defined during testing.
*/1 * Indicates scheduling every minute. www.2cto.com 5. Ensure that the crond service runs properly [root @ czjie ~] #/Sbin/service crond status
Crond (pid 3081) is running... if the service is not running properly, start and close the following method:/sbin/service crond start // start the service.
/Sbin/service crond stop // close the service
/Sbin/service crond restart // restart the service
/Sbin/service crond reload // reload the configuration
/Sbin/service crond reload // view service status
Or
/Etc/init. d/crond start // start the service
/Etc/init. d/crond stop // close the service
/Etc/init. d/crond restart // restart the service
/Etc/init. d/crond reload // re-load the configuration to automatically start the service when the system starts:
Add:
/Sbin/service crond start now, the entire backup configuration process is complete! Because the prompt information related to automatic scheduling is not printed to the terminal window,
Therefore, you can only view the email logs. The statement is as follows: [root @ czjie ~] # Cat/var/mail/oracle
Source: http://www.cnblogs.com/czjie/