2014-04-21 14:44:31 +02:00
|
|
|
mysql_utils for Debian
|
|
|
|
=======================
|
2013-06-12 00:10:39 +02:00
|
|
|
|
|
|
|
Backup and Restore data from MySql tables
|
2013-11-23 18:17:53 +01:00
|
|
|
|
2014-04-21 14:44:31 +02:00
|
|
|
Install
|
|
|
|
======
|
|
|
|
|
|
|
|
cd ~
|
|
|
|
git clone https://github.com/Mirocow/mysql_utils.git
|
|
|
|
cd mysql_utils
|
|
|
|
|
2014-05-23 10:32:45 +02:00
|
|
|
Backup (All Databases)
|
2014-04-21 14:44:31 +02:00
|
|
|
======
|
|
|
|
|
|
|
|
cd ~
|
|
|
|
cd mysql_utils
|
|
|
|
bash backup.sh
|
|
|
|
|
|
|
|
Restore
|
|
|
|
=======
|
|
|
|
|
|
|
|
cd /var/backups/mysql
|
|
|
|
bash ~/mysql_utils/restore.sh
|
|
|
|
|
2014-05-23 10:32:45 +02:00
|
|
|
Restore selected table
|
|
|
|
=======
|
|
|
|
|
|
|
|
cd /var/backups/mysql/[some date]/[some db name]
|
|
|
|
bash ~/mysql_utils/restore_table.sh
|
|
|
|
|
2013-11-23 18:17:53 +01:00
|
|
|
Automation backup with Cron
|
|
|
|
===========================
|
|
|
|
|
2014-04-21 14:16:04 +02:00
|
|
|
nano /etc/default/db_backup
|
|
|
|
|
|
|
|
START=yes
|
|
|
|
|
2013-11-23 18:17:53 +01:00
|
|
|
nano /etc/cron.d/db_backup
|
|
|
|
|
2014-04-21 14:50:26 +02:00
|
|
|
@daily root . /etc/default/db_backup && if [ "$START" = "yes" ] && [ -x /root/mysql_utils/backup.sh ]; \
|
|
|
|
then /bin/bash /root/mysql_utils/backup.sh; fi
|
2014-04-21 14:48:26 +02:00
|
|
|
|
|
|
|
Check work
|
|
|
|
==========
|
|
|
|
|
2014-05-23 10:32:45 +02:00
|
|
|
# tail -f /var/log/syslog
|
|
|
|
May 23 12:25:34 db1 logger: BACKUP: ** Dump tecdoc.2013.ALI_COORD
|
|
|
|
May 23 12:25:35 db1 logger: BACKUP: ** set perm on tecdoc.2013/AL
|
|
|
|
May 23 12:25:35 db1 logger: BACKUP: ** bzip2 tecdoc.2013/ALI_COOR
|
|
|
|
May 23 12:25:35 db1 logger: BACKUP: ** Dump tecdoc.2013.ARTICLES
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** set perm on tecdoc.2013/AR
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** bzip2 tecdoc.2013/ARTICLES
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** Dump tecdoc.2013.ARTICLES_
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** set perm on tecdoc.2013/AR
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** bzip2 tecdoc.2013/ARTICLES
|
|
|
|
May 23 12:25:43 db1 logger: BACKUP: ** Dump tecdoc.2013.ARTICLE_C
|
|
|
|
|