weblogic域備份指令碼

來源:互聯網
上載者:User

標籤:-name   back   echo   red   rom   auth   shell   問題   weblogic域   

一直一來,由於空間問題,weblogic域很少備份,偶爾會手動備份一次,這營運做得不稱職,今天有時間,寫個小指令碼來定時備份。

 

1、指令碼備份檔案目錄結構

[[email protected] ~]$ tree weblogic_bak_shellweblogic_bak_shell|-- exclude.conf|-- logs|   `-- 2017-08-02.log|-- tar.conf`-- weblogic_bak.sh

 2、主備份指令碼

weblogic_bak.sh
#!/bin/bash#############################weblogic備份指令碼            ##2017-08-02                ##Version:1.0              ##Author:jzd           ##說明:                     ##1、需要配置需備份目錄          ##2、排除的檔案或目錄           #############################shell_dir=$(cd $(dirname $0); pwd)source /etc/profilesource ~/.bash_profileif [ ! -f ${shell_dir}/tar.conf  ]; then echo "tar.conf file not exist" exit 1fisource ${shell_dir}/tar.confexe_data=$(date +%F)bak_file_name="weblogic_${exe_data}.tgz"log_file="${shell_dir}/logs/${exe_data}.log"#begin backup[ "${bak_dir}"x != ""x ] && [ "${exclude_file}"x != ""x ] && [ "${dst_bak_dir}"x != ""x ] && tar -zcvpf ${dst_bak_dir}/${bak_file_name} --exclude-from=${exclude_file} ${bak_dir} &> ${log_file} || echo "先決條件不滿足,tar不執行" > ${log_file}#del backif [ -f ${dst_bak_dir}/${bak_file_name} ] && [ "${dst_bak_dir}"x != ""x ] && [ "${expired_days}"x != ""x ]; then  find ${dst_bak_dir} -mtime +${expired_days} -name "weblogic_*-*-*.tgz" | xargs rm -ffiexit $?

 3、設定檔

exclude.conf
[[email protected] weblogic_bak_shell]$ cat exclude.conf *.out*.log*.tar*.tgzserverstemp

 tar.conf

[[email protected] weblogic_bak_shell]$ cat tar.conf bak_dir="/u01/Middleware/user_projects/domains/weblogic"dst_bak_dir="/home/weblogic/weblogic_bak_dir"exclude_file=exclude.confexpired_days=14

 4、加入定時任務

crontab -e

00 19 * * 6 cd /home/weblogic/weblogic_bak_shell && bash weblogic_bak.sh &> /dev/null

 

weblogic域備份指令碼

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.