backup-docker/setup.sh

34 lines
897 B
Bash
Raw Normal View History

2021-11-10 20:27:49 +00:00
#!/usr/bin/env sh
set -e
if [ -z "${RCLONE_CONFIG}" ]; then
RCLONE_CONFIG="/config/rclone.conf"
[ -e "${RCLONE_CONFIG}" ] || echo "No config file found"
echo "\$RCLONE_CONFIG not set. Defaulting to \"/config/rclone.conf\""
fi
export RCLONE_CONFIG
if [ -z "$RCLONE_REMOTE" ]; then
RCLONE_REMOTE="$(rclone listremotes | head -1)/backup"
echo "\$RCLONE_REMOTE not set. Defaulting to \"$RCLONE_REMOTE\""
fi
RESTIC_REPOSITORY="rclone:$RCLONE_REMOTE"
if [ -n "${RESTIC_PASSWORD}" ] && [ -n "$RESTIC_PASSWORD_FILE" ]; then
echo "\$RESTIC_PASSWORD or \$RESTIC_PASSWORD_FILE is not set"
fi
if [ -n "${MYSQL_PASSWORD}" ]; then
MYSQL_PASSWORD_ACTUAL="${MYSQL_PASSWORD}"
elif [ -n "${MYSQL_PASSWORD_FILE}" ]; then
MYSQL_PASSWORD_ACTUAL=$(cat "$MYSQL_PASSWORD_FILE")
fi
export RCLONE_REMOTE
export RESTIC_PASSWORD
export MYSQL_PASSWORD_ACTUAL
export RESTIC_REPOSITORY