Experts share the scheme of automatic backup oracle database

  

Database management is very important, many system users will inevitably encounter forgetting to back up data. If it happens that the system has failed at this time, then we will not be able to do this without a backup database. So, is there any way for our system to automatically back up the database? Of course, our system experts have compiled a tutorial for automatic backup of the Oracle database based on practical experience, and now share it with everyone.

First, export the database

The export command backs up the data in the database into a binary file. It usually has three modes: user mode, table mode and the entire database mode. This article intends to adopt the user mode. Before backup, you should first create a backup directory to accommodate backup files. For example, you can create a /backup directory. Then we can create two files ora—backup, tar—backup in the UNIX directory of UNIX (or other directories). It should be noted that the previous file needs to initialize the parameters of Oracle. For convenience, we may put the initialization command into a file (the file name is set to ora—env), and then it is called by the first file.

1. The ora—env file initializes 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< Br>

ORA—NLS32=$ORACLE—HOME/ocommon/nls/admin/data;export ORA—NLS

PATH=.:/usr/ccs/bin:/usr/ucb:$ORACLE&mdash ;HOME/bin:$PATH;export PATH

DISPLAY=host1:0;export DISPLAY

NLS—LANG=american—america.zhs16cgb231280;export NLS—LANG

2. ora—backup file export export to the database, the exported file name can be arbitrarily determined, this article is set to the letter "xx", plus the date of the day, that is, if the date of the day is December 10, the exported file name is "ld"; Xx1210.dmp” to distinguish backup files from other dates.

ora—backup file contents:

./oracle/ora—env

#initialize Oracle database

rq=′date +″% M%d″ ′

# Assign the date of the day to the variable rq

rm /backup/

# empty/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. Files and logs are placed in the /backup directory.

Second, tape backup

tar—backup file will copy the data file exported by export command to tape.

tar—backup file contents:

tar rvf /dev/rmt/0n/backup/?

This command can back up the files generated in the /backup directory to the day. On the tape. In this file, the tar command uses three parameters, where the r option means copying the file into the tape without destroying the original contents of the tape, the v option means displaying the file information during the copying process, and the f option is followed by the tape device name, specifying Where the file is copied, the n option indicates that the tape drive is not rewinding. /dev/rmt/0 indicates the first tape drive for a UNIX host. Similarly, /dev/rmt/1 indicates the second tape drive for the UNIX host, and so on.

ora—env,ora—backup,tar—after the backup file is written, use the following command:

chmod 755 ora—env

chmod 755 ora—backup

chmod 755 tar—backup

Thus, all three files become executable files.

Copyright © Windows knowledge All Rights Reserved