跳至主要内容

博文

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 --准备一个新的存储库

准备一个新的存储库 将备份保存在的位置称为“存储库”。 本章介绍如何创建(“init”)这样的存储库。 存储库可以存储在本地,也可以存储在某个远程服务器或服务上。 我们将首先介绍使用本地存储库,本章的其余部分涵盖所有其他选项。 一旦你阅读了这里的相关章节,你可以跳到下一章。 本地 要创建存储库 /srv/restic-repo ,请运行以下命令并输入两次相同的密码: $ restic init --repo /srv/restic-repo enter password for new backend: enter password again: created restic backend 085b3c76b9 at /srv/restic-repo Please note that knowledge of your password is required to access the repository. Losing your password means that your data is irrecoverably lost. 警告 记住你的密码很重要! 如果你失去它,你将无法访问存储在存储库中的数据。 对于自动备份,restic接受环境变量中的存储库位置 RESTIC_REPOSITORY 。 密码可以从文件(通过选项 --password-file 或环境变量  RESTIC_PASSWORD_FILE )或环境变量中 读取 RESTIC_PASSWORD 。 SFTP 为了通过SFTP备份数据,您必须先使用SSH设置服务器,并让它知道您的公钥。 无密码登录非常重要,因为如果服务器提示输入凭据,restic无法连接到存储库。 一旦配置了服务器,SFTP存储库的设置就可以通过更改 init 命令中 的URL方案来实现 : $ restic -r sftp:user@host:/srv/restic-repo init enter password for new backend: enter password again: created restic backend f1c6108821 at sftp:user@host:/srv/restic-repo ...