Mysql automatic backup script handout
The following content mainly brings you mysql automatic backup script handouts, the knowledge here is slightly different from books, are summed up by professional and technical personnel in the process of contact with users, have a certain experience sharing value, hope to bring help to the majority of readers.
#! / bin/bash
Bak_dir=/tmp/ `date +% Y% m% d`
Mysqldb=test
Mysqlusr=root
Mysqlpw=123456
Mysqlcmd=/usr/bin/mysqldump
If [$UID-ne 0]; then
Echo "you must be use root"
Exit
Fi
If [!-d $bak_dir]; then
Mkdir-p $bak_dir
Echo "$bak_dir is create ok"
Else
Echo "this $bak_dir is already exists"
Fi
$mysqlcmd-u$mysqlusr-p$mysqlpw $mysqldb > $bak_dir/$mysqldb.sql
If [$?-eq 0]; then
Echo "the database $mysqldb is backup ok"
Else
Echo "the database $mysqldb is backup error"
Fi
Automatic backup
Crontab e
01 00 * / bin/bash / tmp/mysql_back.sh
For the above handouts on mysql automatic backup scripts, if you need to know more, you can continue to follow our industry promotion. If you need professional answers, you can contact the pre-sale and after-sale ones on the official website. I hope this article can bring you some knowledge updates.