From 786a6f9f7ee34f08d636a58b08522fd1ca7450e9 Mon Sep 17 00:00:00 2001 From: Niklas Date: Tue, 30 Mar 2021 22:09:32 +0200 Subject: [PATCH] added mysqldump --- docker-compose.yml | 4 ++++ entrypoint.sh | 7 +++++++ 2 files changed, 11 insertions(+) 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"