Main steps for automatic backup of Oracle databases under UNIX

Source: Internet
Author: User

I believe that many system administrators are doing the same job almost every day, that is, backing up relevant data. In case of negligence one day, and the system suffers some faults on this day, and data recovery is required, there will be nothing to do at this time. Let's talk about the automatic backup of Oracle databases in UNIX environments, which can be used as an example.

We plan to allow the database to perform eXPort backup at a.m., copy the backup file to the tape at a.m., and copy the backup file to another UNIX machine at a.m, to do this, we can perform the following operations:

Export Database

The export command backs up data in the database into a binary file. There are usually three modes: user mode, table mode, and the entire Oracle database mode. This document uses the user mode. before backup, you must create a backup directory to hold backup files. For example, you can create a/backup directory.

Then we can create two files, ora-backup and tar-backup, respectively, in the Oracle directory of UNIX (or another directory. It should be noted that the Oracle parameter needs to be initialized in the previous file. For convenience, we may wish to put the initialization command in a file (the file name should be set to ora-env ), then the first file calls it.

1. The ora-env file initializes Oracle parameters. The content is as follows:

 
 
  1. ORACLE—HOME=$ORACLE—HOME;export ORACLE—HOME   
  2. ORACLE—SID=ora73;export ORACLE—SID   
  3. ORACLE—TERM=sun;export ORACLE—TERM   
  4. LD—LIBRARY—PATH=$ORACLE—HOME/lib;export LD—LIBRARY—PATH   
  5. ORA—NLS32=$ORACLE—HOME/ocommon/nls/admin/data;export ORA—NLS   
  6. PATH=.:/usr/ccs/bin:/usr/UCb:$ORACLE—HOME/bin:$PATH;export PATH   
  7. DISPLAY=host1:0;export DISPLAY   
  8. NLS—LANG=american—america.zhs16cgb231280;export NLS—LANG  

2. the ora-backup file exports the Oracle Database export, and the exported file name can be set at will. This document specifies the letter "xx" and the date of the day, that is, if the date of the day is January 1, December 10, the exported file name is "xx1210.dmp", which is different from the backup file of other dates.

Ora-backup file content:

 
 
  1. ./oracle/ora—env 

Initialize an Oracle database

 
 
  1. rq=′date +″%m%d″ ′ 

Assign the date of the current day to the variable rq

 
 
  1. rm /backup/ 

Clear/backup Directory

 
 
  1. exp test/test file=/backup/xx$rq.dmp log=/backup/xx$rq.log 

This command is used to export the data of the user test (whose password is also test) at the $ prompt. The exported files and logs are stored in the/backup directory.

Article by: http://database.ctocio.com.cn/448/8997448.shtml

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.