add readme and status file

This commit is contained in:
2022-02-09 10:04:28 +01:00
parent a3f5acdaa5
commit b7593a6674
2 changed files with 15 additions and 0 deletions

13
Readme.md Normal file
View File

@@ -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)

View File

@@ -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