backup-docker/src/init.sh

44 lines
1.0 KiB
Bash
Raw Normal View History

2022-03-27 17:28:00 +00:00
#!/usr/bin/env sh
set -e
# if RCLONE_CONFIG_CONTENT is empty and no config file was found
if [ -z "$RCLONE_CONFIG_CONTENT" ] && [ ! -e "${RCLONE_CONFIG:=/config/rclone.conf}" ]; then
echo "No rclone config found"
rclone --config "${RCLONE_CONFIG:=/config/rclone.conf}" config
fi
RCLONE_REMOTE="$(rclone listremotes | head -1)"
echo "Using remote: $RCLONE_REMOTE"
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 ""