九月 22, 2024

rustic 使用说明

rustic 是一个 restic 的独立实现。兼容restic的仓库。提供更多的文件处理能力,比如忽略规则等

首先 rustic 是可以不用配置文件直接备份的

rustic -r rest:http://127.0.0.1:6060 backup /opt

然后,比如我有这个 repo.toml

[global]
log-level = "info"

[repository]
repository = "rest:http://127.0.0.1:6060"
password = "pwd"
cache-dir = "/root/.cache/restic"

然后就可以用这个命令备份,files 文件夹下所有文件不会有任何忽略

rustic -P repo backup /opt/files

然后还有这个文件 iglob.toml

[backup]
label = "vps"
no-require-git = true 
git-ignore = true
custom-ignorefile = [".kopiaignore", ".ignore"]
skip-identical-parent = true 
exclude-if-present = [".nobackup", "CACHEDIR.TAG"] # Default: not set
iglob-file = ["/root/.config/rustic/exclude.glob"]
iglob = ["!/root/rr"]
tag = ["rusitc"]

那这么备份的时候,是遵循忽略配置的

rustic -P repo -P iglob backup /opt/

再加上这个 target.toml

[backup]

[[backup.sources]]
source = "/root "

[[backup.sources]]
source = "/usr/local/lib/systemd/system"

[[backup.sources]]
source = "/opt"

那么备份的时候就自动备份了上面三个文件夹,并且是遵循忽略配置的。

rustic -P repo -P iglob -P target backup

还可以包含一些基础配置来做备份任务 job.data.toml

[global]
use-profile = ["repo","forget"]

[backup]
label = "vps"
tag = ["rustic","couchdb"]
skip-identical-parent = true

[[backup.sources]]
source = [
"/opt/docker/app/couchdb/data"
]

使用如下命令备份 couchdb/data 这个文件夹里所有文件,没有任何忽略

rustic -P job.data backup