[Shell] backup directory v0.1
作者: reistlin
来源: http://www.reistlin.com/blog/190
更新时间: 2011.01
版权声明: 原创文章.转载请保留作者信息和原文完整.谢绝任何方式的摘要
[https://reistlin.googlecode.com/svn/trunk/shell/backup_directory.sh]
#!/bin/bash # name: backup directory v0.1 # author: reistlin # website: www.reistlin.com # date: 2011.01.28 debug="0"; tag="blog"; dir_src="/home/reistlin/blog/"; dir_dst="/home/reistlin/backup/${tag}_`date +'%Y-%m-%d'`.tar.gz"; log="/home/reistlin/backup/${tag}_`date +'%Y-%m-%d'`.log"; md5="/home/reistlin/backup/${tag}_`date +'%Y-%m-%d'`.md5"; del_dir="/home/reistlin/backup/"; del_day="30"; if [ $debug == "1" ]; then echo "[INFO] source path:" $dir_src; echo "[INFO] target path:" $dir_dst; echo "[INFO] save log:" $log; echo "[INFO] save md5:" $md5; echo "[INFO] delete path:" $del_dir; echo "[INFO] delete days:" $del_day; fi cd $dir_src; /bin/tar zcvfpP $dir_dst $dir_src >> $log; /usr/bin/md5sum $dir_dst >> $md5; # delete "N Day*24H+24H" find $del_dir -name "${tag}_*.*" -mtime +${del_day} -exec rm {} \;