zoukankan      html  css  js  c++  java
  • Centos7 增量备份数据脚本

    #!bin/bash
    #Automatic Backup Linux System Files
    #By Author www.jfedu.net
    #Define Variables
    SOURCE_DIR=(
      $*
    )
    TARGETDIR=/data/backup/
    YEAR='date + %Y'
    MONTH='date + %d'
    WEEK='date + %u'
    FILES=system_backuo.tgz
    CODE=$?
    if
      [ -z $SOURCE_DIR]; then
    echo -e "Please Enter a File or Directory You Need to Backup; ------------------------------------------
    ---------------- Example $0 /boot/etc ......"
      exit
    fi
    #Determine Wether the Target Directory Exists
    if
      [! -d $TARGET_DIR/$YEAR/$MONTH/$DAY];then
      mkdir -p $TARGET_DIR/$YEAR/$MONTH/$DAY
      echo "This $TARGET_DIR Created Successfully!"
    fi
    #EXEC Full_Backup Function Command
      Full_Backup()
    {
    if 
      ["$WEEK" -eq "7"];then
      rm -rf $TARGET_DIR/snapshot
      cd $TARGET_DIR/$YEAR/$MONTH/$DAY ; TAR -g $TARGET_DIR/snapshot -czvf $FILES 'echo ${SOURCE_DIR[@]}'
      ["$CODE" == "0"]&&echo -e " -----------------------------------------------------------------------
      - Full_Backup System Files Backup Successfully!"
      fi
    }
    #Perform incremental BACKUP Function Command
    Add_Backup()
    {
      cd $TARGET_DIR/$YEAR/$MONTH/$DAY;
    if
      [ -f $TARGET_DIR/$YEAR/$MONTH/$DAY/$FILES];then
      read -p "$FILES Already Exists,overwrite confirmation yes or no ? : "SURE
      if [$SURE == "no" -o $SURE == "n"];then
      sleep 1 ; exit 0
      fi
    #Add_Backup Files System
      if
        [$WEEK -ne "7" ];then
        cd $TARGET_DIR/$YEAR/$MONTH/$DAY ; tar -g $TARGET_DIR/snapshot -czvf $ $_$FILES
      'echo ${SOURCE_DIR[@]}'
        ["$CODE" =="0"]&&echo -e "--------------------------------------------------------
      - Add_Backup System Files Backup Successfully !"
        fi
      else
        if
          [ $WEEK -ne "7"];then
          cd $TARGET_DIR/$YEAR/$MONTH/$DAY ; tar -g $TARGET_DIR/snapshot -czvf $FILES 'echo $
      {SOURCE_DIR[@]}'
          ["$CODE" == "0"]&&echo -e "--------------------------------------------------------
      - Add_Backup System Files Backup Successfully !"
        fi
      fi
    }
    Full_Backup;Add_Backup
  • 相关阅读:
    Session原理、安全以及最基本的Express和Redis实现
    Docker内核能力机制
    Docker服务端防护
    Docker控制组
    Docker 内核名字空间
    Docker标准化开发测试和生产环境
    Docker多台物理主机之间的容器互联
    Docker创建 tomcat/weblogic 集群
    Docker使用 Supervisor 来管理进程
    Docker实例:创建一个点到点连接
  • 原文地址:https://www.cnblogs.com/aqicheng/p/11051089.html
Copyright © 2011-2022 走看看