I’ve been trying restic for a while, as I need to replace my old homemade rsync scripts, and so far it fits all my requirements. Good work!
One thing that came to me straight away is that it involves a lot of typing. I’m using different Azure backends and I had to juggle with different environment variables with different storage accounts.
Another thing I needed is different profiles: I do local backups of the root to a data disk, a backup to another machine locally, then a backup to an azure storage account. Managing different repositories is not the easiest.
For that matter I’ve created a quick python script that can manage profiles. An example is better than a long discussion, and here’s what it can do right now:
- A simple configuration file using a Microsoft Azure backend:
[default] repository = "azure:restic:/" password-file = "key" [default.env] AZURE_ACCOUNT_NAME = "my_storage_account" AZURE_ACCOUNT_KEY = "my_super_secret_key" [default.backup] exclude-file = "excludes" exclude-caches = true one-file-system = true tag = [ "root" ] source = [ "/", "/var" ]
- A more complex configuration file showing profile inheritance and two backup profiles using the same repository:
# Global configuration section [global] ionice = false # Linux only ionice-class = 2 ionice-level = 6 nice = 10 # All unix-like # when no command is specified when invoking resticprofile default-command = "snapshots" # initialize a repository if none exist at location initialize = false # a group is a profile that will call all profiles one by one [groups] # when starting a backup on profile "full-backup", it will run the "root" and "src" backup profiles full-backup = [ "root", "src" ] # Default profile when not specified (-n or --name) # Please note there's no default inheritance from the 'default' profile (you can use the 'inherit' flag if needed) [default] repository = "/backup" password-file = "key" initialize = false [default.env] TMPDIR= "/tmp" [no-cache] inherit = "default" no-cache = true initialize = false # New profile named 'root' [root] inherit = "default" initialize = true # 'backup' command of profile 'root' [root.backup] exclude-file = [ "root-excludes", "excludes" ] exclude-caches = true one-file-system = false tag = [ "test", "dev" ] source = [ "." ] # retention policy for profile root [root.retention] before-backup = false after-backup = true keep-last = 3 keep-hourly = 1 keep-daily = 1 keep-weekly = 1 keep-monthly = 1 keep-yearly = 1 keep-within = "3h" keep-tag = [ "forever" ] compact = false prune = false # New profile named 'src' [src] inherit = "default" initialize = true # 'backup' command of profile 'src' [src.backup] exclude-file = [ "src-excludes", "excludes" ] exclude-caches = true one-file-system = false tag = [ "test", "dev" ] source = [ "./src" ] # retention policy for profile src [src.retention] before-backup = false after-backup = true keep-within = "30d" compact = false prune = true
Here are a few examples how to run restic (using the example configuration file)
See all snapshots:
Backup root & src profiles (using full-backup group)
python resticprofile.py --name "full-backup" backup
If you guys would have any use of it, I’m happy to release a package on PyPi. I just need to tidy up some loose ends (mostly error checking: for now the script expects a clean configuration file)