备份所有配置文件的好脚本

1 #!/bin/bash 

2 filedate=`date "+%Y%m%d%H%M%S"`

3 list=`find / -name "*.conf" -mtime -1 -o -name "*.vcl" -mtime -1 -o -name "*.cnf" -mtime -1 -o -name "*.ini" -mtime -1`

4 #echo $list

5 for i in $list

6 do

7 #echo $i;

8 filename=${i##*/}

9 echo "filename=>"$filename

10 path=${i%/*}

11 echo "path=>"$path

12 echo "++++++"

13 mkdir -p "/var/www/backup/configure_backup"$path

14 cp -rp $i "/var/www/backup/configure_backup/"$path"/"

15 done;

16 cd /var/www/backup

17 /bin/tar -zcvf "linuxconf"$filedate".tar.gz" "configure_backup"

18 rm -rf /var/www/backup/configure_backup

19 ~

    A+
发布日期:2013年12月17日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: