Created
September 10, 2024 14:32
-
-
Save iwconfig/41109c08bf19effe5df045c38ed29583 to your computer and use it in GitHub Desktop.
Execute restic repository scripts as sub commands of restic itself. E.g. `restic-foo backup [...]` can be executed as `restic foo backup [...]`. Inspired by https://forum.restic.net/t/recipes-for-managing-repository-environment-variables/1716/2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Place this file in /usr/local/bin and make it executable. | |
## reference: https://forum.restic.net/t/recipes-for-managing-repository-environment-variables/1716/2 | |
REPO_NAME="$1" | |
REPO_SCRIPT="/usr/local/sbin/restic-$REPO_NAME" | |
# Check if the corresponding script exists and is executable | |
if [ -x "$REPO_SCRIPT" ]; then | |
shift # Remove the first argument so that $@ contains the rest | |
exec "$REPO_SCRIPT" "$@" | |
else | |
# If no repository script is found, call the original restic command | |
exec /usr/bin/restic "$@" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## Example repo script. Place this file in /usr/local/sbin and `chmod` it to 700 | |
## reference: https://forum.restic.net/t/recipes-for-managing-repository-environment-variables/1716/2 | |
export RESTIC_REPOSITORY=... | |
export RESTIC_PASSWORD=... | |
exec restic "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment