一个使用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
其中….似乎很简单,不用说什么了
延伸阅读
- bash shell下按文件夹快速合并文件
- 高级Bash脚本编程指南
- Bash里有用的命令/bash技巧
- 使用stat命令在shell中读取文件状态(修改时间,大小,权限模式,磁盘占用)
- linux bash Shell脚本经典之Fork炸弹解析:() { :|:& };:
- [转]让你提升命令行效率的 Bash 快捷键
- linux bash下find命令之-exec参数多次使用{}处理匹配到文件
- tar 打包备份目录时分卷打包压缩(增量备份,并自动分割成多个文件)
- linux tar命令详解
- linux下tar命令的奇葩用法(可用来保留目录修改时间的复制整个目录)
- linux下使用tar差异化备份目录
- tar高级教程:增量备份、定时备份、网络备份
- windows下mysql自动定期备份并压缩/以discuz论坛为例
- sql server 2005 使用命令行备份数据
- MySQL 备份和恢复(包括MyISAM 和 Innodb)
先下载了再说,以后慢慢研究!