#!/usr/bin/env sh set -e if [ -n "$RCLONE_CONFIG_FILE" ]; then echo "$RCLONE_CONFIG_FILE" > "${RCLONE_CONFIG:=/config/rclone.conf}" fi 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 if [ -n "$POSTGRES_PASSWORD" ];then PGPASSWORD="$POSTGRES_PASSWORD" elif [ -n "$POSTGRES_PASSWORD_FILE" ]; then PGPASSWORD=$(cat "$POSTGRES_PASSWORD_FILE") fi export RCLONE_REMOTE export RESTIC_PASSWORD export MYSQL_PASSWORD_ACTUAL export RESTIC_REPOSITORY export PGPASSWORD