Oracle Automatic daily backup scripts

Source: Internet
Author: User
Tags dba

Because a backup script for Oracle needs to be written recently, Oracle's data backup is not backed up directly using binary tools like MySQL, and data backup on Oracle needs to be configured so that normal data backup scripts can be configured. So you need to do some configuration before Oracle backs up your data.

First, because of Oracle's 11g start-up feature, empty tables do not allocate tablespace so in the backup script I use the EXPDP tool for data backup, before the backup begins, you need to export the Oracle data Pump directory with the DBA account first to specify and authorize read and write, and then modify the directory of the group, Operation is very simple, is a number of EXPDP data pump operation, this has been explained before, here do not do a description of the length, you can see: http://jim123.blog.51cto.com/4763600/1941618, after setting up a good dpdata1 directory, It is important to also modify the genus of the dpdata1 directory, otherwise the data file exported using EXPDP cannot be written, depending on the group modification permissions defined at the time when Oracle was installed

[Email protected] ~]# chown oracle:oinstall/data/backup/oracle_backup

After modifying the above steps, and then the Oracle user under the Bash_profile configuration file in the installation of the environment variables defined in the script, in the definition of the execution time of the script can be, the implementation of the script is relatively simple, as follows:

#!/bin/bash#oracle_backup.sh version1.0 chmod 700#writer jim#00 00 * *  * /usr/local/scripts/oracle_backup.sh#chmod 700 /usr/local/scripts/oracle_backup.sh#you  must first import the environment variables in the Oracle  User ' S bash_profile file#must be used to define the dba account  first dpdata1 path and authorized directory to read and  write, modify the dpdata1 group#history#2017.07.01export oracle_base=/usr/local/u01/ Oracleexport oracle_home=/usr/local/u01/oracle/product/11.2.0/dbhome_1export oracle_sid= Oracle11export nls_lang= "American_america. ZHS16GBK "export nls_date_format=" Yyyy-mm-dd hh24:mi:ss "export ld_library_path= $ORACLE _home/ Libexport path= $ORACLE _home/bin: $PATHdatetime =$ (date + "%y%m%d") dpdata1_dir= "/data/backup/oracLe_backup "oracle_u01=" u01 "oracle_u02=" u02 "oracle_password1=" U01_password "oracle_password2=" U02_password "EXPDP  ${oracle_u01}/${oracle_password1} directory=dpdata1 dumpfile=${oracle_u01}_${datetime}  Logfile=${oracle_u01}_${datetime}.logif [ $? -ne 0 ];then    echo   "$ (date +"%y-%m-%d_%h:%m:%s ") oracle_${oracle_u01}_backup_file!"  > ${dpdata1_dir}/${datetime}_err.logfiexpdp ${oracle_u02}/${oracle_password2}  directory=dpdata1 dumpfile=${oracle_u02}_${datetime} logfile=${oracle_u02}_${datetime}.logif [  $? -ne 0 ];then    echo  "$ (date +"%y-%m-%d_%h:%m:%s ") Oracle _${oracle_u02}_backup_file! "  >> ${dpdata1_dir}/${datetime}_err.logfi/usr/bin/bzip2 -z ${dpdata1_dir}/*${datetime }*find  $dpdata 1_dir -type f -ctime +30 -name  "*.bz2"  -exec rm  -vf {} \;

Of course, you can also replace the failure of the place with a written e-mail function, in the case of failure to send an e-mail can also

This article from "Technical essay" blog, declined reprint!

Oracle Automatic daily backup scripts

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.