backup-docker/src/init.sh
Djeeberjr 2375406fe0
All checks were successful
continuous-integration/drone/push Build is passing
fixed default RCLONE_REMOTE
2022-03-27 20:29:19 +02:00

47 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
set -e
if [ -n "$RCLONE_CONFIG_CONTENT" ]; then
echo "$RCLONE_CONFIG_CONTENT" > "${RCLONE_CONFIG:=/config/rclone.conf}"
elif [ ! -e "${RCLONE_CONFIG:=/config/rclone.conf}" ]; then
echo "No rclone config found"
rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config
fi
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"
echo "Using repository: $RESTIC_REPOSITORY"
# if RESTIC_PASSWORD is empty
if [ -z "$RESTIC_PASSWORD" ] && [ -z "$RESTIC_PASSWORD_FILE" ]; then
echo "Set \$RESTIC_PASSWORD or \$RESTIC_PASSWORD_FILE"
exit 1
fi
export RCLONE_REMOTE
export RESTIC_REPOSITORY
restic init
echo "Display rclone config [y/N]?"
read -r answer
# check if answer is yes
if [ "$answer" = "y" ] || [ "$answer" = "Y" ]; then
rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config show
echo ""
fi
echo "Environemnt variables:"
echo "RCLONE_REMOTE=$RCLONE_REMOTE"
echo "RESTIC_PASSWORD=*********"
echo "RESTIC_REPOSITORY=$RESTIC_REPOSITORY"
echo ""