From a263b53dc31bef76b8d91d3ad57a273aac11e93b Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Mon, 3 Feb 2020 21:06:20 +0100 Subject: [PATCH] Added mysql backup script --- Dockerfile | 2 +- scripts/mysql_backup.sh | 13 +++++++++++++ scripts/prefilebackup | 3 +++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 scripts/mysql_backup.sh diff --git a/Dockerfile b/Dockerfile index 7a5d9d7..4f3839c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ from debian -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget lftp +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y wget lftp mariadb-client RUN TF=`mktemp` &&\ wget "https://hndl.urbackup.org/Client/latest/update/UrBackupUpdateLinux.sh" -O $TF &&\ diff --git a/scripts/mysql_backup.sh b/scripts/mysql_backup.sh new file mode 100644 index 0000000..241f64a --- /dev/null +++ b/scripts/mysql_backup.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +BACKUP_DIR="/backup/database" + +echo +echo "Starting to backup database" +date +mkdir --parents $BACKUP_DIR +mysqldump --single-transaction --host=$MYSQL_BACKUP_HOST --user=$MYSQL_BACKUP_USER --password=$MYSQL_BACKUP_PASSWORD $MYSQL_BACKUP_DATABASE > $BACKUP_DIR/$MYSQL_BACKUP_DATABASE.sqldump + +echo +echo "Database backup finished" +date diff --git a/scripts/prefilebackup b/scripts/prefilebackup index 70de866..f9c7264 100644 --- a/scripts/prefilebackup +++ b/scripts/prefilebackup @@ -4,3 +4,6 @@ if [[ -z "$DO_FTP_BACKUP" ]]; then sh ftp_backup.sh fi +if [[ -z "$DO_MYSQL_BACUP" ]]; then + sh mysql_backup.sh +fi