added backup scripts

This commit is contained in:
John Lancaster
2024-05-19 20:11:37 -05:00
parent b22f4a436b
commit 29079011d7
5 changed files with 143 additions and 2 deletions

28
scripts/restic_backup.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR)
COMPOSE_FILE=$REPO_DIR/docker-compose.yml
SERVICES="mqtt z2m"
echo -n "Stopping containers..."
docker compose -f $COMPOSE_FILE stop $SERVICES 2>/dev/null
echo "Done"
echo -n "Running backup..."
$SCRIPT_DIR/restic_command.sh backup /data "$@"
echo "Done"
echo -n "Executing compose up..."
docker compose -f $COMPOSE_FILE up -d 2>/dev/null
echo "Done"
echo -n "Pruning restic repo..."
$SCRIPT_DIR/restic_prune.sh 1>/dev/null
echo "Done"
SPACE=$(du -hs /mnt/* | awk '{print $1}')
echo "Total space used: $SPACE"

View File

@@ -3,9 +3,10 @@
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
DATA_DIR=$SCRIPT_DIR/data
REPO_DIR=$(dirname $SCRIPT_DIR)
DATA_DIR=$REPO_DIR
ENV_FILE=$SCRIPT_DIR/.env
ENV_FILE=$REPO_DIR/.env
source $ENV_FILE
docker run -it --rm \

11
scripts/restic_prune.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
$SCRIPT_DIR/restic_command.sh forget --prune \
--keep-last 5 \
--keep-weekly 8 \
--keep-monthly 12 \
--keep-yearly 7