Based on Oracle Linux automatic backup server and the timing Clear

 1, root users to write shell scripts OrclBackup.sh

#!/bin/bash
export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export DATA_DIR=/home/oracle/app/admin/orcl/dpdump
export LOGS_DIR=/home/oracle/app/admin/orcl/dpdump
export DELTIME=`date -d "10 days ago" +%Y%m%d`
export BAKUPTIME=`date +%Y%m%d%H%M%S`
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
echo "Starting bakup..."
echo "Bakup file path $DATA_DIR/$BAKUPTIME.dmp"
expdp scott/tiger@172.168.1.10:1521/orcl dumpfile=$BAKUPTIME.dmp log=$BAKUPTIME.log directory=data_pump_dir
echo "backup file success..."
tar -zcvPf $DATA_DIR/scdzpj$BAKUPTIME.tar.gz $DATA_DIR/scdzpj$BAKUPTIME.dmp $DATA_DIR/scdzpj$BAKUPTIME.log --remove-files
echo "tar the file bakup successfully. "
rm -rf $DATA_DIR/scdzpj$DELTIME*.gz
echo "Bakup completed."

2, add the script to the service

chkconfig --add OrclBackup.sh

3, check whether the added successfully

chkconfig --list | grep OrclBackup.sh

Guess you like

Origin www.cnblogs.com/yangxuyang/p/12529720.html