Files
restic-scripts/restic_command.sh
2024-05-20 19:02:24 -05:00

35 lines
695 B
Bash
Executable File

#!/bin/bash
set -e
SCRIPT_DIR=$(readlink -f $(dirname "${BASH_SOURCE[0]}"))
REPO_DIR=$(dirname $SCRIPT_DIR)
ENV_FILE=$REPO_DIR/.env
echo "Reading env variables from $ENV_FILE"
source $ENV_FILE
if [ -z "$DATA_DIR" ]; then
echo "Error: DATA_DIR is not set."
exit 1
fi
if [ -z "$RESTIC_REPOSITORY" ]; then
echo "Error: RESTIC_REPOSITORY is not set."
exit 1
fi
if [ -z "$RESTIC_PASSWORD" ]; then
echo "Error: RESTIC_PASSWORD is not set."
exit 1
fi
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 "$@"