一个使用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
其中....似乎很简单,不用说什么了
延伸阅读
- linux bash下find命令之-exec参数多次使用{}处理匹配到文件
- [转]让你提升命令行效率的 Bash 快捷键
- 高级Bash脚本编程指南
- bash shell下按文件夹快速合并文件
- 使用stat命令在shell中读取文件状态(修改时间,大小,权限模式,磁盘占用)
- tar 打包备份目录时分卷打包压缩(增量备份,并自动分割成多个文件)
- linux下使用tar差异化备份目录
- linux下tar命令的奇葩用法(可用来保留目录修改时间的复制整个目录)
- ms sql server 2005维护计划(备份)失败:应用于目标服务器 对于 xx 失败
- windows下mysql自动定期备份并压缩/以discuz论坛为例
- 不用“维护计划”实现mssql定期备份并压缩存档
- 使用cygwin在windows下自动备份目录数据/注册cygwin为windows服务
- 生产环境下数据库服务器备份策略参考
- 简单命令对mysql数据库的备份与还原
- 纯文本数据处理的实用脚本(bash,awk)
这个必须得顶啊,好文章!!!