#!/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