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
    
  • 相关阅读:
    vbs习题
    spotlight监控工具使用
    vue 不同路由同一个组件 缓存问题
    iphone手机上3D动画transform:rotateY闪现一下或者不显示
    vue 单独引用sass文件
    cnpm安装 npm安装node-sass报错
    webpack 打包css时提示Unexpected character '@'
    window下npm启动报错This is probably not a problem with npm. There is likely additional logging output above.
    HBuilder 配置android模拟器
    windows 切换git远程仓库地址后 git push 提示Authentication failed
  • 原文地址:https://www.cnblogs.com/jjzd/p/7275056.html
Copyright © 2011-2022 走看看