zoukankan      html  css  js  c++  java
  • Linux shell 对数据进行归档

      1 #!/bin/bash
      2
      3 DATE=$(date +%y%m%d)
      4 FILE=archive$DATE.tar.gz
      5 #The path to store the files you need to archive
      6 CONFIG_FILE=/tmp/zhangxl/file_to_archive
      7 DESTINATION=/tmp/zhangxl/$FILE
      8
      9 if [ -f $CONFIG_FILE ]
     10 then
     11     echo
     12 else
     13     echo
     14     echo "$CONFIG_FILE dose not exist"
     15     echo "Backup not completed due to missing Configuration File"
     16     echo
     17     exit
     18 fi
     19
     20 FILE_NO=1

     21 #Redirect Std Input to name of Config File
     22 exec < $CONFIG_FILE
     23 read FILE_NAME
     24 while [ $? -eq 0 ]
     25 do
     26     echo "file_name:" $FIEL_NAME
     27     if [ -f $FILE_NAME -o -d $FILE_NAME ]
     28     then
     29 #   FILE_LIST="$FILE_NAME"

        #注意这个变量,我过与自信,手打变量,结果打错了,拼写成FIEL,造成没有输出
     30         FILE_LIST="$FILE_LIST $FILE_NAME"    
     31         echo "==FILE_LIST==" $FILE_LIST
     32         echo
     33     else
     34         echo
     35         echo "$FILE_NAME ,dose not exist"
     36         echo "Obviously, I will not include it in this archive."
     37         echo "It is listed on line $FILE_NO of the config file."
     38         echo "Continuing to build archive list..."
     39         echo
     40     fi
     41     FILE_NO=$[$FILE_NO + 1 ]
     42     read FILE_NAME
     43 done
     44 echo "Startin archive . . ."
     45 echo
     46 tar  -zcf $DESTINATION   $FILE_LIST  2>/dev/null
     47 echo "Archive completed"
     48 echo "Resulting archive file is :$DESTINATION"
     49 echo
     50 exit

  • 相关阅读:
    centos下升级python
    微信公众号(二)
    微信公众号的开发(一)
    nginx 新手入门
    Mysql is not allowed to connect mysql server
    docker 新手入门 (阿里镜像仓库的使用)
    docker 新手入门 (web项目的部署)
    jquery easyui combox不能编辑只能选择
    $.messager.confirm 用法
    html下载excel模板
  • 原文地址:https://www.cnblogs.com/z977690557/p/14087203.html
Copyright © 2011-2022 走看看