Skip to content
bkuhl edited this page Feb 15, 2012 · 10 revisions

What is Smart MySQL Backup?

Smart MySQL Backup is a simple shell script controlled by a configuration file. When the script runs it will perform backups as it is configured and output a result of what took place.

Example output:

Loading config file (/path/to/mysql-backup.conf)
Created backup directory (/path/to/backups/latest/2012-02-11)
Backing up MySQL databases...
    - database1...
    - database2...
    - database3...
    - database4...
Performing backup rotation...
Backups rotation complete
MySQL backup is complete
--------------
/usr/local/mysql/bin/mysql  Ver 14.12 Distrib 5.0.18, for pc-linux-gnu (i686) using readline 5.0

Connection id:		579247
Current database:	
Current user:		root@My.server
SSL:     			Not in use
Current pager:		stdout
Using outfile:		''
Using delimiter:	;
Server version:		5.0.26
Protocol version:	10
Connection:		    192.168.255.xx via TCP/IP
Server characterset:	utf8
Db     characterset:	utf8
Client characterset:	utf8
Conn.  characterset:	utf8
TCP port:		3306
Uptime:			37 days 15 hours 8 min 41 sec

Threads: 10  Questions: 225667986  Slow queries: 147  Opens: 326131  Flush tables: 1  Open tables: 64  Queries per second avg: 69.408
--------------

How can I get it setup and running?

Simply configure a few settings in mysql-backup.conf and add a cron: 15 3 * * * /path/to/mysql-backup.sh

This will run daily at 3:15 AM server time.

How can I get an email report when my backups run?

It's a good idea to setup daily emails so you know if your backups failed. Use the following command to get the output delivered to your inbox: 15 3 * * * /path/to/mysql-backup.sh 2>&1 | /usr/bin/mail -s "Backup Report" myEmail@gmail.com

Clone this wiki locally