Package: resticprofile
resticprofileConfiguration profiles manager forrestic backupresticprofileis the missing link between a configuration file and restic backup. Creating a configuration file for restic has beendiscussed before, but seems to be a very low priority right now.The configuration file isTOMLformat:You no longer need to remember command parameters and environment variablesYou can create multiple profiles inside a configuration fileA profile can inherit the options from another profileYou can run the forget command before or after a backup (in a section calledretention)You can check a repository before or after a backupYou can create groups of profiles that will run sequentiallyYou can run shell commands before or after a backupAllows to start the restic process usingnice(not available on Windows) and/orionice(only available on Linux)Requirementsresticprofileneeds python >=3.5 installed on your machine.It's been actively tested on macOS X and Linux, and regularly tested on Windows.This is atbetastage. Please don't use it in production yet. Even though I'm using it on my servers, I cannot guarantee all combinations of configuration are going to work properly for you.Installresticprofileis published onPython Package Index.
The easiest way to install resticprofile is usingpip:python3 -m pip install --user --upgrade resticprofileConfiguration formatA configuration is a set ofprofiles.Each profile is in its own[section].Inside each profile, you can specify different flags for each command.A command definition is[section.command].All the restic flags can be defined in a section. For most of them you just need to remove the two dashes in front.To set the flag--password-file password.txtyou need to add a line likepassword-file = "password.txt"There's oneexception: the flag--repois namedrepositoryin the configurationLet's say you normally use this command:restic --repo "local:/backup" --password-file "password.txt" --verbose backup /homeFor resticprofile to generate this command automatically for you, here's the configuration file:[default]repository="local:/backup"password-file="password.txt"[default.backup]verbose=truesource=[ "/home" ]You may have noticed thesourceflag is accepting an array of values (inside brakets)Now, assuming this configuration file is namedprofiles.confin the current folder, you can simply runresticprofile backupConfiguration examplesHere's 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=trueone-file-system=truetag=[ "root" ]source=[ "/", "/var" ]Here's a more complex configuration file showing profile inheritance and two backup profiles using the same repository:[global]# ionice is available on Linux onlyionice=falseionice-class=2ionice-level=6# nice is available on all unixes (macOs X included)nice=10# run 'snapshots' when no command is specified when invoking resticprofiledefault-command="snapshots"# initialize a repository if none exist at locationinitialize=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 profilesfull-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=trueinitialize=false# New profile named 'root'[root]inherit="default"initialize=true# 'backup' command of profile 'root'[root.backup]exclude-file=[ "root-excludes", "excludes" ]exclude-caches=trueone-file-system=falsetag=[ "test", "dev" ]source=[ "." ]# retention policy for profile root[root.retention]before-backup=falseafter-backup=truekeep-last=3keep-hourly=1keep-daily=1keep-weekly=1keep-monthly=1keep-yearly=1keep-within="3h"keep-tag=[ "forever" ]compact=falseprune=false# if path is NOT specified, it will be copied from the 'backup' source# path = []# the tags are NOT copied from the 'backup' commandtag=[ "test", "dev" ]# host can be a boolean ('true' meaning current hostname) or a string to specify a different hostnamehost=true# New profile named 'src'[src]inherit="default"initialize=true# 'backup' command of profile 'src'[src.backup]run-before=[ "echo Starting!", "ls -al ./src" ]run-after="echo All Done!"exclude=[ '/**/.git' ]exclude-caches=trueone-file-system=falsetag=[ "test", "dev" ]source=[ "./src" ]check-before=true# retention policy for profile src[src.retention]before-backup=falseafter-backup=truekeep-within="30d"compact=falseprune=trueAnd another simple example for Windows:[global]restic-binary="c:\\ProgramData\\chocolatey\\bin\\restic.exe"# 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="local:r:/"password-file="key"initialize=false# New profile named 'test'[test]inherit="default"initialize=true# 'backup' command of profile 'test'[test.backup]tag=[ "windows" ]source=[ "c:\\" ]check-after=truerun-before="dir /l"run-after="echo All Done!"Simple example sending a file via stdin[stdin]repository="local:/backup/restic"password-file="key"[stdin.backup]stdin=truestdin-filename="stdin-test"tag=[ 'stdin' ]Using resticprofileHere are a few examples how to run resticprofile (using the main example configuration file)See all snapshots (assuming your default python is python3):python -m resticprofileOr if the folder~/.local/bin/is in your PATH, simplyresticprofileBackup root & src profiles (usingfull-backupgroup shown earlier)python -m resticprofile --name "full-backup" backupAssuming thestdinprofile from the configuration file shown before, the command to send a mysqldump to the backup is as simple as:mysqldump --all-databases | python3 -m resticprofile -n stdin backupMount the default profile (default) in /mnt/restic:python -m resticprofile mount /mnt/resticDisplay quick helppython -m resticprofile --help

Usage:
 resticprofile
   [--no-ansi]
   [-c|--config <configuration_file>]
   [-h|--help]
   [-n|--name <profile_name>]
   [-q|--quiet]
   [-v|--verbose]
   [restic command] [additional parameters to pass to restic]Command line referenceThere are not many options on the command line, most of the options are in the configuration file.[-h]: Display quick help[-c | --config] configuration_file: Specify a configuration file other than the default[-n | --name] profile_name: Profile section to use from the configuration file[-q | --quiet]: Force resticprofile and restic to be quiet (override any configuration from the profile)[-v | --verbose]: Force resticprofile and restic to be verbose (override any configuration from the profile)[--no-ansi]: Disable console colouring (to save output into a log file)[restic command]: Like snapshots, backup, check, prune, forget, mount, etc.[additional flags]: Any additional flags to pass to the restic command lineConfiguration file reference[global]None of these flags are passed on the restic command lineionice: true / falseionice-class: integerionice-level: integernice: true / false OR integerdefault-command: stringinitialize: true / falserestic-binary: string[profile]Flags used by resticprofile onlyinherit: stringinitialize: true / falseFlags passed to the restic command linecacert: stringcache-dir: stringcleanup-cache: true / falsejson: true / falsekey-hint: stringlimit-download: integerlimit-upload: integerno-cache: true / falseno-lock: true / falseoption: string OR list of stringspassword-command: stringpassword-file: stringquiet: true / falserepository: string(will be passed as 'repo' to the command line)tls-client-cert: stringverbose: true / false OR integer[profile.backup]Flags used by resticprofile onlyrun-before: string OR list of stringsrun-after: string OR list of stringscheck-before: true / falsecheck-after: true / falseFlags passed to the restic command lineexclude: string OR list of stringsexclude-caches: true / falseexclude-file: string OR list of stringsexclude-if-present: string OR list of stringsfiles-from: string OR list of stringsforce: true / falsehost: stringiexclude: string OR list of stringsignore-inode: true / falseone-file-system: true / falseparent: stringstdin: true / falsestdin-filename: stringtag: string OR list of stringstime: stringwith-atime: true / falsesource: string OR list of strings[profile.retention]Flags used by resticprofile onlybefore-backup: true / falseafter-backup: true / falseFlags passed to the restic command linekeep-last: integerkeep-hourly: integerkeep-daily: integerkeep-weekly: integerkeep-monthly: integerkeep-yearly: integerkeep-within: stringkeep-tag: string OR list of stringshost: true / false OR stringtag: string OR list of stringspath: string OR list of stringscompact: true / falsegroup-by: stringdry-run: true / falseprune: true / false[profile.snapshots]Flags passed to the restic command linecompact: true / falsegroup-by: stringhost: true / false OR stringlast: true / falsepath: string OR list of stringstag: string OR list of strings[profile.forget]Flags passed to the restic command linekeep-last: integerkeep-hourly: integerkeep-daily: integerkeep-weekly: integerkeep-monthly: integerkeep-yearly: integerkeep-within: stringkeep-tag: string OR list of stringshost: true / false OR stringtag: string OR list of stringspath: string OR list of stringscompact: true / falsegroup-by: stringdry-run: true / falseprune: true / false[profile.check]Flags passed to the restic command linecheck-unused: true / falseread-data: true / falseread-data-subset: stringwith-cache: true / false[profile.mount]Flags passed to the restic command lineallow-other: true / falseallow-root: true / falsehost: true / false OR stringno-default-permissions: true / falseowner-root: true / falsepath: string OR list of stringssnapshot-template: stringtag: string OR list of strings