跳至主要内容

Restic --恢复

从备份恢复

从快照恢复

恢复快照非常简单,只需使用以下命令将最新快照的内容恢复到 /tmp/restore-work
$ restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work
enter password for repository:
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
使用这个词latest来恢复上次备份。您还可以结合 latest使用过滤器--host--path过滤器来为特定主机,路径或两者选择上次备份。
$ restic -r /srv/restic-repo restore latest --target /tmp/restore-art --path "/home/art" --host luigi
enter password for repository:
restoring <Snapshot of [/home/art] at 2015-05-08 21:45:17.884408621 +0200 CEST> to /tmp/restore-art
使用--exclude并将--include还原限制为快照中文件的子集。例如,要恢复单个文件:
$ restic -r /srv/restic-repo restore 79766175 --target /tmp/restore-work --include /work/foo
enter password for repository:
restoring <Snapshot of [/home/user/work] at 2015-05-08 21:40:19.884408621 +0200 CEST> to /tmp/restore-work
这会将文件恢复foo/tmp/restore-work/work/foo

使用mount进行恢复

将您的备份作为常规文件系统浏览也非常简单。首先,创建一个安装点/mnt/restic,然后使用以下命令通过FUSE提供存储库:
$ mkdir /mnt/restic
$ restic -r /srv/restic-repo mount /mnt/restic
enter password for repository:
Now serving /srv/restic-repo at /mnt/restic
Don't forget to umount after quitting!
在OpenBSD,Solaris / Illumos和Windows上无法通过FUSE挂载存储库。
Restic支持硬链接的存储和保存。但是,由于硬件链接按照定义存在于文件系统的范围内,因此应通过保留硬链接的程序来恢复保险丝安装的硬链接。这样做的程序rsync与选项-hard-links一起使用。

将文件打印到标准输出

有时将文件打印到标准输出是有帮助的,以便其他程序可以直接读取数据。这可以通过使用dump命令来实现,如下所示:
$ restic -r /srv/restic-repo dump latest production.sql | mysql

评论

此博客中的热门博文

Restic --备份

备份 现在我们准备好备份一些数据。 在特定时间点的目录内容在restic中被称为“快照”。 运行以下命令并再次输入上面选择的存储库密码: $ restic -r /srv/restic-repo --verbose backup ~/work open repository enter password for repository: password is correct lock repository load index files start scan start backup scan finished in 1.837s processed 1.720 GiB in 0:12 Files: 5307 new, 0 changed, 0 unmodified Dirs: 1867 new, 0 changed, 0 unmodified Added: 1.700 GiB snapshot 40dc1520 saved 正如你所看到的,restic创建了该目录的备份并且速度非常快! 40dc1520 在这种情况下 ,刚刚创建的特定快照由一系列十六进制字符标识 。 如果你没有通过这个 --verbose 选项,restic将打印更少的数据(但你仍然会得到一个很好的实时状态显示)。 如果再次运行该命令,restic将会创建另一个数据快照,但这次更快。 这是工作中的重复数据删除! $ restic -r /srv/restic-repo backup --verbose ~/work open repository enter password for repository: password is correct lock repository load index files using parent snapshot d875ae93 start scan start backup scan finished in 1.881s processed 1.720 GiB in 0:03 Files: 0 new, 0 changed, 5307 unmodified Dirs...

Restic --删除备份快照

删除备份快照 所有的备份空间都是有限的,所以restic可以删除旧的快照。 这可以通过手动(通过指定要删除的快照ID)或者使用描述要忘记哪些快照的策略来完成。 对于所有删除操作,需要依次调用两个命令: forget 删除快照并 prune 实际删除快照从存储库中引用的数据。 这可以通过 forget 命令 --prune 选项 来自动 执行, 如果快照已被删除 ,该 prune 命令 会自动 运行 。 建议 在修剪后 运行 restic   check ,以确保提醒您可能的损坏存储库的内部数据结构。 删除一个快照 该命令 snapshots 可用于列出存储库中的所有快照,如下所示: $ restic -r /srv/restic-repo snapshots enter password for repository: ID Date Host Tags Directory ---------------------------------------------------------------------- 40dc1520 2015-05-08 21:38:30 kasimir /home/user/work 79766175 2015-05-08 21:40:19 kasimir /home/user/work bdbd3439 2015-05-08 21:45:17 luigi /home/art 590c8fc8 2015-05-08 21:47:38 kazik /srv 9f0bc19e 2015-05-08 21:46:11 luigi /srv 要删除快照 /home/art ,请使用该 forget  命令并在命令行上指定快照ID: $ restic -r /srv/restic-repo forget bdbd3439 enter password for repository: removed snapshot d3f01f63 之后,此快照被删除: $ restic -r...

Restic --安装

安装 包 请注意,如果您尝试使用的软件包过时,您始终可以选择使用restic项目中的官方二进制文件。 这些是最新的二进制文件,以可重复和可验证的方式构建,无需额外安装即可下载和运行。 请参阅 下面 的 官方二进制文件 部分进行各种下载。 Mac OS X 如果您使用Mac OS X,则可以使用 自制 软件包管理器 安装Restic  : $ brew install restic Arch Linux 在 Arch Linux上 ,有一个包 restic-git  可以从AUR安装,例如 pacaur : $ pacaur -S restic-git Nix和NixOS 如果您使用的是 Nix 或 NixOS  ,则会提供一个名为的软件包 restic 。 它可以安装uisng  nix-env : $ nix-env --install restic Debian的 在Debian上,有一个 restic 可以从官方回购站安装 的软件包 ,例如 apt-get : $ apt-get install restic 警告 请注意,在写作的时候,Debian的 稳定  具有 restic 版本0.3.3这是很老了。 该 测试 和 不稳定  分支有最新版本 restic 。 RHEL和CentOS restic可以通过copr存储库进行安装。 $ yum install yum-plugin-copr $ yum copr enable copart/restic $ yum install restic Fedora的 restic可以通过copr存储库进行安装。 $ dnf install dnf-plugin-core $ dnf copr enable copart/restic $ dnf install restic 独自的 restic可以通过 eopkg 包管理器 从Solus的官方回购安装 : $ eopkg install restic OpenBSD系统 在OpenBSD ...