Home > mysql-backup

mysql-backup

Mysql-backup is a project mainly written in Ruby, based on the MIT license.

A backup tool for MySQL.

h1. mysql-backup

A command line tool that backups all MySQL database instances it can find on a MySQL server.

h2. Installation


  $ sudo gem install mysql_backup —source http://gemcutter.org

You can also grab the source code and install with rake:


  $ cd /usr/local/src
  $ git clone git://github.com/christianhellsten/mysql-backup.git
  $ cd mysql-backup
  $ sudo rake install

h2. Configuration

Configuration is easy, just run the built-in mysql_backup_install command:


  $ sudo mysql_backup_install

The installation script will ask you to enter all necessary information and then writes the configuration to /etc/mysql_backup.

h2. Usage

Taking a backup of all databases is also easy:


  $ sudo mysql_backup

This will backup all databases, except the ones defined in the configuration file using the skip parameter.

h2. Scheduled backups with cron

Open the cron configuration with the following command:


$ sudo crontab -e

Add the following:


PATH=/usr/local/bin:/usr/bin:/bin
SHELL=/bin/bash

# m h  dom mon dow   command

# Backup all MySQL databases every night at 24:00

00 00 * * * mysql_backup

h2. Sample configuration


user: root
password: xxx
host: localhost
dir: /var/backup
format: %d-%m-%y
keep: 10

mysqldump:
  options: -Q -c -C --add-drop-table --add-locks --quick --lock-tables
  path:
skip: [mysql, test, information_schema]

h2. TODO

  • Refactor
  • List dependencies
  • Handle command line errors gracefully
  • Nice

h2. Author

"Christian Hellsten":http://christianhellsten.com ("Aktagon Ltd.":http://aktagon.com)