Проект

Общее

Профиль

MySQL backup » История » Версия 4

Версия 3 (Dmitry Chernyak, 23.11.2011 16:14) → Версия 4/5 (Dmitry Chernyak, 23.11.2011 16:16)

h1. MySQL backup

We're backing up MySQL database using the backup mysql via shutdown/startup procedure.

Despite
shutdown/startup.
There are
some disadvantages, it will be the best choice but, in common for many sites because: this will be a good choce because
* This is much faster than the dump in the backup.
* This is very much faster than the restoring from the dump.
* This allowing to not differ between MyISAM and InnoDB.
* This allowing to save traffic via duplicity's block-based incremental alogrithms (implemented via librsync).

To do the backup you have to place the following files in your mysql backup job's profile.

profile:
File "pre"
<pre>
if [ `ps ax|grep mysqld|grep -v grep|wc -l` -eq 0 ]; then
mysql_stopped=yes
echo "Warning: MySQL is not running."
else
/etc/init.d/mysql stop
sleep 5
if [ `ps ax|grep mysqld|grep -v grep|wc -l` -gt 0 ]; then
echo "Error: MySQL is not stopped. Skiping backup"
exit 1
fi
fi
</pre>

File "post"
<pre>
if [ -z "$mysql_stopped" ]; then
/etc/init.d/mysql start
sleep 5
if [ `ps ax|grep mysqld|grep -v grep|wc -l` -eq 0 ]; then
echo "Error: MySQL is not restarted properly. Take care."
exit 1
fi
fi
</pre>