initial commit
This commit is contained in:
25
restic_backup.sh
Executable file
25
restic_backup.sh
Executable file
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
COMPOSE_FILE=$SCRIPT_DIR/docker-compose.yml
|
||||
|
||||
SERVICES="server db"
|
||||
|
||||
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"
|
||||
18
restic_command.sh
Executable file
18
restic_command.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
DATA_DIR=$SCRIPT_DIR/data
|
||||
|
||||
ENV_FILE=$SCRIPT_DIR/.env
|
||||
source $ENV_FILE
|
||||
|
||||
docker run -it --rm \
|
||||
--hostname $HOSTNAME \
|
||||
--env-file $ENV_FILE \
|
||||
-v /etc/localtime:/etc/localtime:ro \
|
||||
-v /etc/timezone:/etc/timezone:ro \
|
||||
-v $DATA_DIR:/data \
|
||||
-v $RESTIC_REPOSITORY:$RESTIC_REPOSITORY \
|
||||
restic/restic:latest "$@"
|
||||
11
restic_prune.sh
Executable file
11
restic_prune.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
|
||||
$SCRIPT_DIR/restic_command.sh forget --prune \
|
||||
--keep-last 5 \
|
||||
--keep-hourly 72 \
|
||||
--keep-daily 14 \
|
||||
--keep-weekly 8 \
|
||||
--keep-monthly 12 \
|
||||
--keep-yearly 7
|
||||
14
restic_restore.sh
Executable file
14
restic_restore.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
|
||||
COMPOSE_FILE=$SCRIPT_DIR/docker-compose.yml
|
||||
|
||||
echo "Stopping containers"
|
||||
docker compose -f $COMPOSE_FILE stop 2>/dev/null
|
||||
|
||||
SNAPSHOT_ID=${1:-latest}
|
||||
$SCRIPT_DIR/restic_command.sh --verbose restore $SNAPSHOT_ID:/data --target /data
|
||||
|
||||
echo "Executing compose up"
|
||||
docker compose -f $COMPOSE_FILE up -d 2>/dev/null
|
||||
echo "Done"
|
||||
Reference in New Issue
Block a user