diff --git a/docker-compose.yml b/docker-compose.yml index aeb94ef..c6ed8d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,10 @@ services: - RCLONE_REMOTE=gdrive:/backupTest - RCLONE_CONFIG=/config/rclone.conf - RESTIC_PASSWORD=repopw + - MYSQL_USERNAME=dbuser + - MYSQL_PASSWORD=dbPassword + - MYSQL_DUMP_DB=dbName1,dbName2 + - MYSQL_HOST=mariadb volumes: - ./mounts:/backup - ./config:/config \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh index 86a0099..374a091 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -6,4 +6,11 @@ set -e [ -z "${RCLONE_CONFIG}" ] && echo "\$RCLONE_CONFIG is not set" && exit 1 [ -z "${RESTIC_PASSWORD}" ] && echo "\$RESTIC_PASSWORD is not set" && exit 1 +mkdir -p /backup/sqlDump + +for db in ${MYSQL_DUMP_DB//,/ } +do + mysqldump --compact -P 3306 --host $MYSQL_HOST -u "$MYSQL_USERNAME" "-p$MYSQL_PASSWORD" "$db" > "/backup/sqlDump/$db.sql" +done + restic -r "rclone:$RCLONE_REMOTE" --verbose backup "/backup"