Compare commits

1 Commits
main ... cv

Author SHA1 Message Date
5753b425d6 Sanitized for CV
Some checks failed
Configure Kumonoboru / deploy (push) Has been cancelled
2023-11-21 23:01:20 +02:00

View File

@@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
##Simple script to run Restic backups ## Script to run Restic backups to a B2 backend.
## It makes sure each of the preconfigured repositories can be safely backed up.
show_help() show_help()
{ {
@@ -8,11 +9,11 @@ show_help()
echo " {-r|--repository} repository -- Only backup the specified repository." echo " {-r|--repository} repository -- Only backup the specified repository."
echo " {-l|--limit} #[Kbps] -- Limit upload & download speed" echo " {-l|--limit} #[Kbps] -- Limit upload & download speed"
echo " {-v|--verbose} -- Print debug messages" echo " {-v|--verbose} -- Print debug messages"
echo " {-h|--show_help} -- Print this show_help message and exit" echo " {-h|--show_help} -- Print this show_help message and exit"
echo "Available repositories:" echo "Available repositories:"
echo "Gerbil-TK Photos (path: /var/Red-Vol/Media/Pictures)" echo "REPO-1 stuff (path: /stuff/stuff1)"
echo "Pukeko-XYZ-Containers Containers (path: /var/Red-Vol/Media/Containers)" echo "REPO-2 other stuff (path: /stuff/stuff2)"
echo "Pukeko-XYZ-Cloud Data from all devices (path: /var/Red-Vol/Media/Cloud)" echo "REPO-3 more stuff (path: /stuff/stuff3)"
exit 0 exit 0
} }
#Pass arguments to the script #Pass arguments to the script
@@ -44,7 +45,7 @@ flags()
} }
flags "$@" flags "$@"
#Defaults ## Defaults
if [[ -z $BWLIMIT ]]; then if [[ -z $BWLIMIT ]]; then
export BWLIMIT="0" export BWLIMIT="0"
else else
@@ -57,10 +58,6 @@ if [[ -n $REPOSITORY ]]; then
echo -e "Will only process repository" "$1" echo -e "Will only process repository" "$1"
fi fi
export B2_ACCOUNT_ID=8582a42a3b99 #Master Key
export B2_ACCOUNT_KEY=00041845e8dd29d7e3d091d77bb8a631ee71332be7 #Master Application ID
RESTIC_PASSWORD='f$774$#je4%U8vp8ov*UsZMHqL$m3Smh#fEbbt7hyULQxfnnWmSiS5MEndzVWT$$n^@s$P*o4vV*^rgv3jvvrv@y35VppU$$y*vnG5V@botU&4$39Y6t9HSb3Z548M!4'
#Safety function; accepts repository to check #Safety function; accepts repository to check
safety(){ safety(){
@@ -131,24 +128,24 @@ clean(){
#If cleaning was forced, or if it's the first of this month - clean. #If cleaning was forced, or if it's the first of this month - clean.
if [[ -n $CLEAN ]] || [[ $(date +%d) == "1" ]]; then if [[ -n $CLEAN ]] || [[ $(date +%d) == "1" ]]; then
check Gerbil-TK check REPO-1
clean Gerbil-TK clean REPO-1
check Pukeko-XYZ-Containers check REPO-2
clean Pukeko-XYZ-Containers clean REPO-2
check Pukeko-XYZ-Cloud check REPO-3
clean Pukeko-XYZ-Cloud clean REPO-3
#If a specific repository was requested, back it up; otherwise, back them all up. #If a specific repository was requested, back it up; otherwise, back them all up.
elif [[ -n $REPOSITORY ]] && [[ -z $CLEAN ]]; then elif [[ -n $REPOSITORY ]] && [[ -z $CLEAN ]]; then
case "$REPOSITORY" in case "$REPOSITORY" in
(Gerbil-TK) (REPO-1)
backup Gerbil-TK /var/Red-Vol/Media/Pictures/ backup REPO-1 /stuff/stuff1/
;; ;;
(Pukeko-XYZ-Containers) (REPO-2)
backup Pukeko-XYZ-Containers /var/Red-Vol/Media/Containers/ backup REPO-2 /stuff/stuff2/
;; ;;
(Pukeko-XYZ-Cloud) (REPO-3)
backup Pukeko-XYZ-Cloud /var/Red-Vol/Media/Cloud/ backup REPO-3 /stuff/stuff3/
;; ;;
(*) (*)
show_help;; show_help;;
@@ -156,24 +153,24 @@ elif [[ -n $REPOSITORY ]] && [[ -z $CLEAN ]]; then
#If cleaning was not forced, backup the repositories #If cleaning was not forced, backup the repositories
elif [[ -z $CLEAN ]]; then elif [[ -z $CLEAN ]]; then
backup Gerbil-TK /var/Red-Vol/Media/Pictures/ backup REPO-1 /stuff/stuff1/
backup Pukeko-XYZ-Containers /var/Red-Vol/Media/Containers/ backup REPO-2 /stuff/stuff2/
backup Pukeko-XYZ-Cloud /var/Red-Vol/Media/Cloud/ backup REPO-3 /stuff/stuff3/
#If a specific repository was requested to be cleaned, clean it #If a specific repository was requested to be cleaned, clean it
elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then elif [[ -n $REPOSITORY ]] && [[ -n $CLEAN ]]; then
case "$REPOSITORY" in case "$REPOSITORY" in
(Gerbil-TK) (REPO-1)
check Gerbil-TK check REPO-1
clean Gerbil-TK clean REPO-1
;; ;;
(Pukeko-XYZ-Containers) (REPO-2)
check Pukeko-XYZ-Containers check REPO-2
clean Pukeko-XYZ-Containers clean REPO-2
;; ;;
(Pukeko-XYZ-Cloud) (REPO-3)
check Pukeko-XYZ-Cloud check REPO-3
clean Pukeko-XYZ-Cloud clean REPO-3
;; ;;
(*) (*)
show_help;; show_help;;