restic/restic

GitHub Trending (daily) 工具

摘要

restic 是一个快速、安全且高效的备份程序,支持多种操作系统和后端,如 S3、SFTP 和本地存储。

快速、安全、高效的备份程序
查看原文
查看缓存全文

缓存时间: 2026/06/11 13:33

restic/restic

来源:https://github.com/restic/restic

文档(https://restic.readthedocs.io/zh-cn/latest/?badge=latest) 构建状态(https://github.com/restic/restic/actions?query=workflow%3Atest) Go 报告卡(https://goreportcard.com/report/github.com/restic/restic)

简介

restic 是一款备份程序,快速、高效且安全。它支持三大主流操作系统(Linux、macOS、Windows)以及一些较小的系统(FreeBSD、OpenBSD)。

详细的使用和安装说明请参阅文档(https://restic.readthedocs.io/zh-cn/latest)。

您可以在我们的 Discourse 论坛(https://forum.restic.net)提问。

快速开始

一旦您安装(https://restic.readthedocs.io/zh-cn/latest/020_installation.html)了 restic,首先为您的备份创建一个仓库:

$ restic init --repo /tmp/backup
输入新后端的密码:
再次输入密码:
在 /tmp/backup 创建了 restic 后端 085b3c76b9
请注意,访问仓库需要知道您的密码。
丢失密码意味着您的数据将无法恢复。

然后添加一些数据:

$ restic --repo /tmp/backup backup ~/work
输入仓库密码:
扫描 [/home/user/work]
扫描了 764 个目录,1816 个文件,耗时 0:00
[0:29] 100.00%  54.732 MiB/s  1.582 GiB / 1.582 GiB  2580 / 2580 个文件  0 错误  预计剩余时间 0:00
持续时间:0:29,54.47 MiB/s
快照 40dc1520 已保存

接下来,您可以使用 restic restore 恢复文件,或者使用 restic mount 通过 FUSE 挂载仓库并浏览之前快照中的文件。

更多选项请查看在线文档(https://restic.readthedocs.io/zh-cn/latest/)。

后端

将备份保存在同一台机器上固然不错,但这并非真正的备份策略。因此,restic 原生支持以下后端来存储备份:

  • 本地目录(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#local)
  • SFTP 服务器(通过 SSH)(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#sftp)
  • HTTP REST 服务器(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#rest-server)(协议(https://restic.readthedocs.io/zh-cn/latest/100_references.html#rest-backend),rest-server(https://github.com/restic/rest-server))
  • Amazon S3(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#amazon-s3)(可以是 Amazon 官方或使用 Minio(https://minio.io)服务器)
  • OpenStack Swift(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#openstack-swift)
  • BackBlaze B2(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#backblaze-b2)
  • Microsoft Azure Blob 存储(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#microsoft-azure-blob-storage)
  • Google Cloud 存储(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#google-cloud-storage)
  • 以及通过 rclone(https://rclone.org)后端(https://restic.readthedocs.io/zh-cn/latest/030_preparing_a_new_repo.html#other-services-via-rclone)支持的许多其他服务

设计原则

Restic 是一款正确进行备份的程序,其设计遵循以下原则:

  • 简单:备份应该是一个无摩擦的过程,否则您可能会想跳过它。Restic 应易于配置和使用,以便在数据丢失时能轻松恢复。同样,恢复数据也不应复杂。

  • 快速:使用 restic 备份数据的速度应仅受网络或硬盘带宽的限制,以便您可以每天备份文件。如果耗时过长,没人愿意做备份。恢复备份时,应仅传输恢复所需文件的数据,从而使该过程也很快。

  • 可验证:比备份更重要的是恢复,因此 restic 让您可以轻松验证所有数据是否都能恢复。

  • 安全:Restic 使用密码学来保证数据的机密性和完整性。备份数据的存储位置被认为是不受信任的环境(例如共享空间,系统管理员等其他人可能访问您的备份)。Restic 旨在保护您的数据免受此类攻击者的侵害。

  • 高效:随着数据的增长,额外的快照应仅存储实际增量部分。更重要的是,重复数据应在写入存储后端之前进行去重,以节省宝贵的备份空间。

可重现构建

从 0.6.1 版本开始,每个 restic 版本发布的二进制文件都是可重现的(https://reproducible-builds.org/),这意味着您可以根据该版本的源代码重现字节完全相同的版本。如何操作的具体说明包含在构建仓库中(https://github.com/restic/builder)。

新闻

您可以在 Mastodon @resticbackup(https://fosstodon.org/@restic)上关注 restic 项目,或订阅项目博客(https://restic.net/blog/)。

许可证

Restic 基于 BSD 2-Clause 许可证(https://opensource.org/licenses/BSD-2-Clause)发布。您可以在 LICENSE 中找到完整文本。

赞助

Google Cloud 存储和 Microsoft Azure Blob 存储的后端集成测试由 AppsCode(https://appscode.com)赞助!

由 AppsCode(https://appscode.com)赞助

相似文章

rustdesk/rustdesk

GitHub Trending (daily)

RustDesk 是一款用 Rust 编写的开源远程桌面解决方案,开箱即用,支持自托管,让用户完全掌控自己的数据。

Cloudback

Product Hunt

Cloudback 为 Linear 工作区提供自动化备份与恢复。

Rift:Git Worktrees 的更优替代方案

Hacker News Top

Rift 是一个命令行工具,提供比 Git worktrees 更好的替代方案,通过写时复制快照在 Linux 的 btrfs 和 macOS 的 APFS 上实现快速创建工作区。