2021-07-02 17:56:14 +00:00
|
|
|
#!/usr/bin/env sh
|
2021-03-29 20:28:09 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[ -z "${RCLONE_REMOTE}" ] && echo "\$RCLONE_REMOTE is not set" && exit 1
|
|
|
|
[ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1
|
2021-06-17 20:49:09 +00:00
|
|
|
|
2021-07-02 18:02:42 +00:00
|
|
|
if [ -n "${ENC_PASSWORD}" ]; then
|
2021-06-17 20:49:09 +00:00
|
|
|
RESTIC_PASSWORD="${ENC_PASSWORD}"
|
2021-07-02 18:02:42 +00:00
|
|
|
elif [ -n "${ENC_PASSWORD_FILE}" ]; then
|
2021-06-30 22:04:44 +00:00
|
|
|
RESTIC_PASSWORD=$(cat "$ENC_PASSWORD_FILE")
|
2021-06-17 20:49:09 +00:00
|
|
|
else
|
|
|
|
echo "\$ENC_PASSWORD or \$ENC_PASSWORD_FILE is not set" && exit 1
|
|
|
|
fi
|
|
|
|
|
2021-07-02 18:02:42 +00:00
|
|
|
if [ -n "${MYSQL_PASSWORD}" ]; then
|
2021-06-17 20:49:09 +00:00
|
|
|
MYSQL_PASSWORD_ACTUAL="${MYSQL_PASSWORD}"
|
2021-07-02 18:02:42 +00:00
|
|
|
elif [ -n "${MYSQL_PASSWORD_FILE}" ]; then
|
2021-06-30 22:04:44 +00:00
|
|
|
MYSQL_PASSWORD_ACTUAL=$(cat "$MYSQL_PASSWORD_FILE")
|
2021-06-17 20:49:09 +00:00
|
|
|
fi
|
2021-03-29 20:28:09 +00:00
|
|
|
|
2021-03-30 20:09:32 +00:00
|
|
|
mkdir -p /backup/sqlDump
|
|
|
|
|
2021-06-30 22:04:44 +00:00
|
|
|
for db in $(echo "$MYSQL_DUMP_DB" | sed 's/,/\n/g')
|
2021-03-30 20:09:32 +00:00
|
|
|
do
|
2021-03-30 20:15:57 +00:00
|
|
|
echo "Dumping db: $db"
|
2021-06-30 22:04:44 +00:00
|
|
|
mysqldump --compact -P 3306 --host "$MYSQL_HOST" -u "$MYSQL_USERNAME" "-p$MYSQL_PASSWORD_ACTUAL" "$db" > "/backup/sqlDump/$db.sql"
|
2021-03-30 20:09:32 +00:00
|
|
|
done
|
|
|
|
|
2021-06-30 22:04:44 +00:00
|
|
|
export RESTIC_PASSWORD
|
|
|
|
|
2021-03-29 20:28:09 +00:00
|
|
|
restic -r "rclone:$RCLONE_REMOTE" --verbose backup "/backup"
|