一个使用tar实现对目录作增量备份的bash脚本
#!/bin/bash #program: # auto backup the folder $to_backup # to $save_to # History: # 2012/11/28 yqf First release # do NOT change the variable $filename # except you REALY know what you are doing exactly filename=`date +%Y%m%d_%H%M%S` # sample # ##whitch folder you want to backup, full path (start with "/") #to_backup="/var/www/html/foo" # ##where you whant to save the backup files,folder, MUST end by "/" #save_to="/var/www/backup/foo/" # ##the incremental file, file name, full path #incremental_file="/var/www/backup/incremental_file/foo.incre" # #tar -g $incremental_file \ # ## each files or folders that no need to backup, (ingore), # ## [Careful] without end slash even folder # -C $to_backup \ # --exclude data/cache \ # --exclude data/tmp \ # -cpjf $save_to$filename.tar.bz2 . # sample end # # mysite.com to_backup="/var/www/html/mysite/html/" save_to="/home/myhome/backup/mysite/" incremental_file="/home/myhome/backup/incremenntal_list/mysite.increment_file" tar -g $incremental_file \ -C $to_backup \ --exclude data/static_cache \ --exclude data/templates_c \ --exclude data/templates_cache \ --exclude data/cache \ -cpjf $save_to$filename.tar.bz2 .
下载脚本附件 tar_incremental_backup_sample
其中….似乎很简单,不用说什么了
这个必须得顶啊,好文章!!!