backup-docker/src/init.sh

45 lines
1.1 KiB
Bash
Raw Normal View History

2022-03-27 17:28:00 +00:00
#!/usr/bin/env sh
set -e
2022-03-27 18:27:10 +00:00
if [ -n "$RCLONE_CONFIG_CONTENT" ]; then
echo "$RCLONE_CONFIG_CONTENT" > "${RCLONE_CONFIG:=/config/rclone.conf}"
elif [ ! -e "${RCLONE_CONFIG:=/config/rclone.conf}" ]; then
2022-03-27 17:28:00 +00:00
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 ""