From b7593a667481f4b78765e843975eeefc8802eba1 Mon Sep 17 00:00:00 2001 From: Thomas Constans Date: Wed, 9 Feb 2022 10:04:28 +0100 Subject: [PATCH] add readme and status file --- Readme.md | 13 +++++++++++++ mysql_backup.sh | 2 ++ 2 files changed, 15 insertions(+) create mode 100644 Readme.md diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..2d51057 --- /dev/null +++ b/Readme.md @@ -0,0 +1,13 @@ +# Mysql backup + +create dump of all mysql databases, one file per database + +including grants + +backups done in /root/backups/mysql - you can pass it another dir as argument too + +depends on a default files (default /root/.my.cnf) containing credentials + +Keeps 15 (can be changed) days of backup + +create a status file containing exit code (you should monitor that file mtime and content) \ No newline at end of file diff --git a/mysql_backup.sh b/mysql_backup.sh index ffc066d..ddc1b23 100755 --- a/mysql_backup.sh +++ b/mysql_backup.sh @@ -9,6 +9,7 @@ defaultfile=/root/.my.cnf rdir=${1:-/root/backups/mysql} dir=${rdir}/$(date "+%Y.%m.%d") error=0 +status_file=/var/run/backup_mysql.status mkdir -p $dir cd $dir @@ -33,4 +34,5 @@ while read uh; do mysql --defaults-file=${defaultfile} -BNe "show grants for $uh if [ $error -eq 0 ] ; then find $rdir -maxdepth 1 -type d -mtime +${rotate} -exec rm -fr {} \; fi +echo $error > $status_file exit $error