Script automatically backs up Oracle databases and deletes backups up to a specified number of days under Linux

Source: Internet
Author: User

#!/bin/bash# set Oracle Database run account and Oracle's system environment variables Export oracle_base=/data/oracleexport oracle_home= $ORACLE _ Base/product/10gexport oracle_sid=testexport path= $ORACLE _home/bin: $HOME/bin: $PATHexport  ld_ Library_path= $ORACLE _home/lib: $ORACLE _home/network/libexport lang=zh_cn. Utf-8export nls_lang= ' Simplified chinese_china. ZHS16GBK ' #获取系统当前日期时间date = ' date +%y%m%d%h%m%s ' #设置删除60天之前的备份文件days =60# back up the data below this user orowner=oracle# Backing up the database name bakuser=user# perform a backup of the password bakpass=pass# backup file path, you need to create a good bakdir=/data/backup/oracle/backup/in advance #备份数据库名称bakdata =$ Orowner "_" $date. dump# the log file name that is generated when the backup executes baklog= $orowner "_" $date. log# Last saved Oracle database backup file ordatabak= $orowner "_" $ date.tar.gz# Enter directory cd  $bakdir # Perform backup exp  $bakuser/$bakpass  grants=y owner= $bakuser  file=$ bakdir/$bakdata  log= $bakdir/$baklog  &> /dev/null# compressed backup files and log files tar -zcf $ ordatabak  $bakdata   $baklog # Delete backup files find  $bakdir  -type f -name  "*.log"  - Exec rm {}  \; #删除日志文件find   $bakdir  -type f -name  "*.dump"  -exec rm {}   \; #删除60天前的备份find   $bakdir  -type f -name  "*.tar.gz"  -mtime + $days   -exec rm -rf {} \;

This article is from the "Chase Dream" blog, please be sure to keep this source http://sihua.blog.51cto.com/377227/1966422

Script automatically backs up Oracle databases and deletes backups up to a specified number of days under Linux

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.