Using restic and resticprofile to implement automatic backup
Table of Contents
Intro
Prerequisite
- restic
- resticprofile
Get Started
实际上我们只需要配置好 resticprofile 就行了。
Make config
mkdir -p ~/.config/resticprofile/ touch profiles.toml
Setup config
version = "1" [default] # local mean in backup in this computer repository = "local:/path/to/backup" password-file = "/path/to/password-file" verbose = true [project1] inherit = "default" initialize = true [project1.backup] source = [ "/path/to/source-file-1", "/path/to/source-file-2", "/path/to/source-file-3" ] # backup every day at 3 a.m. schedule = "03:00" schedule-permission = "user" schedule-lock-wait = "2h" [project1.retention] before-backup = false after-backup = true # keep the newest one keep-last = 1 # keep the newest one in this week keep-weekly = 1 prune = true [project2] inherit = "default" initialize = true [project2.backup] prune = true verbose = true source = [ # ... ] # backup every Monday at 4 a.m. schedule = "Mon 04:00" schedule-permission = "user" schedule-lock-wait = "2h" [project2.retention] before-backup = false after-backup = true keep-last = 1 prune = true
Begin backup
resticprofile init resticprofile --name project1 backup resticprofile --name project2 backup
Set schedule
sudo resticprofile -c ~/.config/resticprofile/profiles.toml schedule --all
check
resticprofile -n default snapshots --latest 1