我把备份oracle以及上传备份服务器的脚本贴出来给你们做一下参考。
[[email protected] ~]-cat expDB_DailyBackup.sh
#---------------------------Set Parameter----------------------------------------
ENVFILE="/etc/profile"
EXITCODE=0
uDate=`date +‘%Y%m%d‘`
Week=`date +‘%a‘`
dbBackup=/home/app/backup/db_Daily
tarName=app_${uDate}_DB_DailyBk.tar.gz
#---------------------------Exit Program----------------------------------------
exit_handler()
{
exit $EXITCODE
}
#---------------------------Load the environment file----------------------------------------
if [ -r "$ENVFILE" ]
then
source $ENVFILE
else
EXITCODE=-1
exit_handler
fi
#---------------------------Backup Application To Directory----------------------------------------
cd $dbBackup
# Export Database To File
exp app_admin/app_admin file=app_${uDate}_DB_DailyBk.dmp
#---------------------------Send The File To Remote Host----------------------------------------
cd $dbBackup
tar -zcvf $tarName app_${uDate}_DB_DailyBk.dmp
# Rename Backup For Remote Host
cp $tarName app_${Week}_DB_DailyBk.tar.gz
lftp << EOF
open sftp://10.0.0.18:1022
user backup [email protected]#
cd db_Daily
put app_${Week}_DB_DailyBk.tar.gz
exit
EOF
# Delete Rename Backup
rm -f app_${Week}_DB_DailyBk.tar.gz
rm -f app_${uDate}_DB_DailyBk.dmp
# Exit Shell Script
exit_handler
crontab设置定时任务,每天23:55分开始备份。
# app Daily Backup
55 23 * * * sh /home/app/bin/expDB_DailyBackup.sh
原文地址:https://blog.51cto.com/13231454/2447242
时间: 2024-10-09 12:45:59