You could also put like a file with the environment inside like you do, but instead of source every time you use restic, make a bash script call it (use a friendly name for your
env files with an extension like
.rc, for example, and
chmod 700 every one of them):
# rc files to work with
# if rc file does not exists exit with code 1
if [[ ! "$rc_file" ]] ; then
echo "You have not indicated a repo to work with"
elif [[ ! -e "$rc_dir/$rc_file.rc" ]] ; then
echo "There is no 'rc' file called $rc_file"
# source rc files
# report errors (if any) stored in catch_errors variable and exit the script
# with the same error or exit 0 if there is no errors
if [[ $"catch_errors" -ne 0 ]]; then
echo "Script finished with errors"
echo "Exit code $catch_errors"
echo "$(basename $0) finished without errors"
This way you can manage multiple repositories. Just have to name them with a friendly name and call them like this:
scriptname reponame [restic_commands_flags_etc]".
I used this script (author @sulfuror) and simplified it to just wrap restic without any functions but the original script have a lot of functions and it is really long. I use it, tho. It simplifies a lot of basic restic commands and it have a nice output, log, etc, but it does not report any errors.