Oracle automatically backs up data

Source: Internet
Author: User
Tags oracle database backup

It is believed that a large number of system administrators are doing the same job every day-backing up the data. Once a day of negligence, and this day the system is precisely the fault, the need for data recovery, then there is nothing at this time. If you set a fixed time every day, the system automatically backup, then how good! The following author combined with practical experience, to talk about the UNIX environment of Oracle database automatic backup, to play a useful role.

We plan to have the database export backup at 23 o'clock in the evening, copy the backup files to tape at 2 o'clock in the morning, and copy the backup files to another UNIX machine at 4 o'clock in the morning, so we can do the following:

First, export the database

The export command backs up data from the database into a binary file, which typically has three modes: User mode, table mode, and the entire database schema. This article is intended to take user mode, before backup, should establish a backup directory to accommodate backup files, such as a/backup directory can be built. We can then create two file Ora-backup,tar-backup in the Unix Oracle directory (or other directories). To be sure, the previous file needs to initialize the parameters of Oracle, and for convenience, we might want to put the initialization command in a file (the filename is ora-env), and then call it by the first file.

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

Oracle-home=$oracle-home;export Oracle-home

Oracle-sid=ora73;export Oracle-sid

Oracle-term=sun;export Oracle-term

Ld-library-path=$oracle-home/lib;export Ld-library-path

Ora-nls32=$oracle-home/ocommon/nls/admin/data;export Ora-nls

path=.:/ Usr/ccs/bin:/usr/ucb:$oracle-home/bin:$path;export PATH

Display=host1:0;export DISPLAY

Nls-lang=american-america.zhs16cgb231280;export Nls-lang

2. ora-backup files to export the database, export the file name can be set arbitrarily, this article is defined as the letter "XX" plus the day date, that is, if the day date is December 10, then the exported file name "Xx1210.dmp" to distinguish the other date of the backup file.

Ora-backup File Contents:

./oracle/ora-env

# Initialize Oracle Database

Rq=′date +″%m%d″′

# Assign the day date to the variable RQ

Rm/backup/

# Empty the/backup directory

Exp Test/test file=/backup/xx$rq.dmp Log=/backup/xx$rq.log

This command is used to export the test user's data (the password is also test) at the $ prompt, and the exported files and logs are placed under the/backup directory.

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.