Using Crontab to implement timed backup of Oracle database

Source: Internet
Author: User
Tags chmod oracle database
Guide:
  
Timed hot Backup (EXP) for an Oracle database can usually be implemented in two ways, one in the Oracle database
Implemented by using the task Queue Manager provided by it (Job queue), or by using the operating system's timed execution commands
To complete. In the first method, the database is required to start the background process SNP, and it needs to be included in the Oracle initialization file
The startup parameters of the task queue, and the second method does not require any changes to the database. This example describes how to use the
Digital a timed trigger crontab under Unix 4.0F to complete a hot backup of the Oracle8i database.
How to use a command
1, the use of Crontab method
Crontab is a timed task trigger under a UNIX system whose user permissions are recorded in the following two files:
/usr/var/adm/cron/cron.deny: The user listed in this file is not allowed to use the crontab command;
/usr/var/adm/cron/cron.allow: The user listed in this document is allowed to use the crontab command;
The format of the crontab command is: crontab? l|-v|-r|-e [Username], whose parameters mean as table one:
The use method of table one crontab parameter
  
The crontab file created by the user is stored in/var/spool/cron/crontabs and has the same filename as the user name.
Its format is divided into six paragraphs, the first five paragraphs for the time set segment, the sixth paragraph is the command segment to be executed, the format is as follows:
* * * * *
The meaning of its time period is as table two:
Table two meaning of time period in crontab file
  
For example: if the contents of the user's crontab file are: * * * * echo its dinner time, then the system per
2, the use of exp method
EXP is a hot backup command for an Oracle database, which is frequently used in the following format:
Exp userid file= ... owner=[username]
Because the parameters of exp command are more, this is not introduced here, the reader can understand the exp command by the EXP help=y command
The use of item parameters, the following only the meaning of the three parameters that will be used to introduce to everyone, see table three:
Table three common parameters of exp
  
Ii. Methods of implementation
Suppose the owner of the database is Oracle and the user of the database is Scott, whose password is trigger,oracle data
The parameters of the library are $oracle_home to/usr/oracle, and $ORACLE _sid is ORCL, the following steps are implemented:
1, the establishment of the Shell to achieve backup
In/usr/oracle, the file backup.sh is established with the VI command, and its contents are:
Oracle_home=/usr/oracle;
Export Oracle_home;
ORACLE_SID=ORCL;
Export Oracle_sid;
/usr/oracle/bin/exp Scott/trigger file=/usr/oracle/backup.dmp Owner=scott
Use the chmod command to modify the properties of backup.sh to perform:
chmod +x backup.sh
Up to this, an executable (shell) backup.sh with backup capabilities has been built. The result of the execution is that Scott
The Oracle object is backed up into the backup.dmp in/usr/oracle, and the reader can run it directly to see the effect
。 It is noteworthy that the two environment parameters of Oracle in backup.sh must be declared, otherwise the system will complain. Next
2, view the use of crontab rights
Log in as Superuser (root) and view Cron.deny with vi command under/usr/var/adm/cron
, if the database owner Oracle is listed inside, delete it.
3, the establishment of Oracle CRONTAB files
Log on with an Oracle user to start building an Oracle user's crontab by using the command crontab e Oracle
* * 1-5 "/usr/oracle/backup.sh"
After you have saved the file, you will find a new one named Oracle in/var/spool/cron/crontabs
Used in Monday to Friday every day of the 17:00 run "/usr/oracle/backup.sh".
By doing so, the system sends the information for each backup to the Oracle user in the form of mail. In the above
Action, it is recommended that you prepare crontab files for other users in the/var/spool/cron/crontabs (especially root)
, lest misoperation affect the system.

This article turns from
Http://www.4oa.com/Article/html/11/69/692/2005/31420.html
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.