zoukankan      html  css  js  c++  java
  • weblogic域备份脚本

    一直一来,由于空间问题,weblogic域很少备份,偶尔会手动备份一次,这运维做得不称职,今天有时间,写个小脚本来定时备份。

    1、脚本备份文件目录结构

    [weblogic@mylinux ~]$ tree weblogic_bak_shell
    weblogic_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/profile
    source ~/.bash_profile
    if [ ! -f ${shell_dir}/tar.conf  ]; then
     echo "tar.conf file not exist"
     exit 1
    fi
    source ${shell_dir}/tar.conf
    exe_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 back
    if [ -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 -f
    fi
    
    exit $?
    

     3、配置文件

    exclude.conf
    [weblogic@mylinux weblogic_bak_shell]$ cat exclude.conf 
    *.out
    *.log
    *.tar
    *.tgz
    servers
    temp
    

     tar.conf

    [weblogic@mylinux 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.conf
    expired_days=14
    

     4、加入定时任务

    crontab -e

    00 19 * * 6 cd /home/weblogic/weblogic_bak_shell && bash weblogic_bak.sh &> /dev/null
    
  • 相关阅读:
    Time
    算法与结构
    11
    DateUtils
    Ext.container.Container
    Ext.Component
    extjs布局--只看现象
    Ext下的方法
    充血模式与贫血模式
    ext下的组建,mvc,mvvm
  • 原文地址:https://www.cnblogs.com/jjzd/p/7275056.html
Copyright © 2011-2022 走看看