add readme and status file
This commit is contained in:
13
Readme.md
Normal file
13
Readme.md
Normal 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)
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user