oracle 数据库备份脚本 oracle自动备份脚本

11/28 10:19:09 来源网站:268辅助卡盟网

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 数据库压缩结束--------------------------------------------------------";

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 传输备份文件开始--------------------------------------------------------";

# echo "scp ${local_backup_dir}/${db_server}_${date_now}.tar.gz ${backup_user}@${backup_server}:/${remote_backup_dir}";

# scp ${local_backup_dir}/${file_name}_${db_server}_${date_now}.tar.gz ${backup_user}@${backup_server}:/${remote_backup_dir};

/home/oracle/auto_scp.sh >> /home/oracle/auto_scp.log

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 传输备份文件结束--------------------------------------------------------";

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 删除当前备份原始文件开始----------------------------------------------";

echo "rm -rf ${local_backup_dir}/${db_server}_${date_now}.dmp ${local_backup_dir}/${db_server}_${date_now}.log"

rm -rf ${local_backup_dir}/${file_name}_${db_server}_${date_now}.dmp ${local_backup_dir}/${file_name}_${db_server}_${date_now}.log;

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 删除当前备份原始文件结束 ----------------------------------------------";

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 删除一个月前备份压缩文件开始----------------------------------------------";

# echo "rm -rf ${local_backup_dir}/${db_server}_${date_now}.tar.gz"

# rm -rf ${local_backup_dir}/${db_server}_${date_now}.tar.gz;

find ${local_backup_dir} -mtime +30 -type f -name "*.*" -exec rm -rvf {} ;

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 删除一个月前备份压缩文件结束----------------------------------------------";

echo "-- $(date +'%Y-%m-%d %H:%M:%S') 自动备份数据库并压缩结束----------------------------------------------";

chmod +x /shell/backup_oracle.sh

crontab -e

0 1 * * * nohup /usr/bin/sh /shell/backup_oracle.sh >> /shell/backup_oracle.log &

vim auto_scp.sh

#! /usr/bin/expect

set timeout 5

set date_now $(date +%Y%m%d);

# set ip 10.180.39.8[lindex $argv 0]

set password "app@2022"

spawn scp /opt/oracle/app/admin/orcl/dpdump/Aj_orcl_$date_now.tar.gz app@10.180.39.85:/sdb5/dmpbackup83/

#expect "yes/no"

#send "yesn"

expect "password:"

send "$passwordn"

interact

来源:【九爱网址导航www.fuzhukm.com】 免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    暂无相关资讯
oracle 数据库备份脚本 oracle自动备份脚本