文章摘要
文章介绍了如何利用rsync工具实现类似macOS Time Machine的时间点备份功能。作者分享了自己因误删文件而开始使用rsync创建时间快照备份的经验,并提供了一个简短的脚本示例,说明如何通过rsync实现高效可靠的增量备份方案。
文章总结
使用rsync实现时光机式备份
作者Sam Hewitt在个人博客中分享了一种利用rsync工具创建时间点备份的方法,灵感来源于macOS的Time Machine功能。
数据备份需求
作者拥有近十年的数字备份数据(尤其是照片),但直到最近因误操作删除未备份文件后,才开始重视创建时间点快照备份。他原本使用兼容macOS Time Machine的家用服务器方案,但随着数据存储习惯改变,这一方案不再适用。
rsync快照方案
作者推荐使用rsync工具实现增量备份,并提供了核心脚本:
1. 脚本通过--link-dest参数创建硬链接,避免重复存储相同文件内容
2. 每次备份生成带时间戳的新目录(格式:YYYY-MM-DDTHH-MM-SS)
3. 自动维护"current"符号链接指向最新备份
4. 备份失败时会重命名目录并保留日志
实施建议
- 将脚本保存为可执行文件(如/usr/local/bin/rsync-time-machine)
- 通过cron设置定时任务(示例为每天凌晨5点执行)
- 删除旧快照时需谨慎,建议先创建完整备份
作者特别致谢Mike Rubel的相关技术文章对其方案的启发。
(注:原文中与主题无关的"Recent Posts"等版块内容已省略)
评论总结
总结评论内容:
关于备份工具的讨论:
- 多位用户推荐restic、borg等专业备份工具,认为它们比简单的rsync脚本更可靠
- "borg has basically solved backups permanently. It's deduplicated, even across snapshots, compressed, and end-to-end encrypted" (LeoPanthera)
- "restic to s3 has been very reliable - haven't tried borg" (mattbillenstein)
对rsync方案的看法:
- 部分用户肯定这种简单方案的价值
- "I've been using a bash encapsulation of this for a long time, works great" (hughc)
- "the simplicity of this script in charming" (nine_k)
与Time Machine的比较:
- 指出Time Machine利用FSEvents的优势
- "Apple Time Machine is fast, as it does not need to walk through the whole filesystem" (deng)
- "TM integration is just so convenient..." (cyberax)
类似工具提及:
- 多位用户提到rsnapshot、rdiff-backup、timeshift等类似工具
- "Seems similar to rsnapshot" (nightshift1)
- "sounds similar to rdiff-backup" (nocman)
技术实现讨论:
- 讨论与ZFS/LVM/BTRFS等文件系统结合的可能性
- "Need to combine this with LVM or BTRFS or similar to be a true snapshot" (theteapot)
- "it would be possible to make a snapshot before the diffing and sending" (nine_k)