Oracle Database Shell Backup script

Source: Internet
Author: User

1. Create a backup path under the root user:

mkdir /opt/backupchown oralce:oinstall /opt/backup

2. Oracle user creates backup script path:

mkdir /opt/app/oracle/bincd /opt/app/oracle/bin

3. Create a backup script

vi backup.sh#!/bin/shexport ORACLE_BASE=/opt/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1export PATH=$PATH:$ORACLE_HOME/bin:.export ORACLE_SID=zd#export NLS_LANG=american_america.UTF8#export NLS_LANG=AMERICAN_AMERICA.AL32UTF8CURDATE=$(date ‘+%Y%m%d%H%M%S‘)backup_directory=/opt/backup/data_file_prefix=zdBACKUP_FILE=$backup_directory/zd$CURDATE.dmpdelete_prev_month_data_file(){    premonth=$(date -d"5 days ago" ‘+%Y%m%d‘)    rm -rf $backup_directory/$data_file_prefix$premonth* || true}#exp zd/[email protected] FILE=$BACKUP_FILE tablespaces=‘zd‘exp zdwebsite/[email protected] FILE=$BACKUP_FILE owner=‘zdweb‘delete_prev_month_data_fileexit 0

4. Scheduled Tasks

crontab -e0 5 * * * /opt/app/oracle/bin/backup.sh

5, crontab Description:
The first * represents minutes per hour of execution 0-59

The second * represents hours per day of the first few hours of execution 0-23

The third * represents the day of the month of the day of execution 1-31

Fourth * indicates the monthly calendar of the month to execute 1-12

The fifth * represents the day of the week of weekly execution 0-6

Oracle Database Shell Backup script

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.