From e659f919c442fba7162bc84b4ceae90e7426447d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rasmus=20Vester=20Th=C3=B8gersen?= Date: Fri, 26 Sep 2025 22:19:25 +0200 Subject: [PATCH] Add initial version of repo setup script --- setup_repo.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 setup_repo.sh diff --git a/setup_repo.sh b/setup_repo.sh new file mode 100644 index 0000000..476549a --- /dev/null +++ b/setup_repo.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +#This script will automatically make an encrypted backup to a restic repository as specified with --source +# + +helpFunction() +{ + echo "" + echo "Usage: $0 -i INPUT -c CONFIG_DIR -l LOG_DIR" + echo -e "\t-i Input folder to create a repository for." + echo -e "\t-c Location of config directory where the repository, password and uuid files are stored." + exit 1 # Exit script after printing help +} + +while getopts "i:c:l:" opt +do + case "$opt" in + i ) INPUT="$OPTARG" ;; + c ) CONFIG_DIR="$OPTARG" ;; + ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent + esac +done + +SERVICE=${INPUT##*/} +SERVICE=${SERVICE,,} + +PASSWORD=$(tr -dc 'A-Za-z0-9!?%=' < /dev/urandom | head -c 50) +UUID=$(uuidgen) + +echo $PASSWORD > $CONFIG_DIR/${SERVICE}_password +echo $UUID > $CONFIG_DIR/${SERVICE}_uuid + +echo "Created required backup directories for $INPUT" +echo "Password: $PASSWORD" +echo "UUID: $UUID" +echo "Make sure to note this down in your password manager to be able to decrypt the repositories, and to map the repositories on the external storage" + +