There are a variety of MySQL database backup solutions out there, but I have been a fan of shell scripts as they are lightweight and bullet-proof.
This script supports:
- MySQL, MariaDB, PostGRE
- daily and hourly backups
- daily, weekly and monthly rotating backups
- email delivery of backups
- database and table selection
- compression
- email notification of log or email delivery of backup
This script is released under the GPLv3 license and is an extensive re-write based on the good work of wipe_out and infyquest.
Download
backupdb v4.0b 34KB
Installing
Download the shell script.
On UNIX/LINUX, copy to /usr/local/bin
Using backupmysql
Invoke backupdb from the command-line.
[root@oobleck ~]# backupdb -h +--------------------------------------------------------------------+ | | | backupdb | | | | Version 4.0b | | | | Copyright (c) 2002 - 2015 | | License GPLv3 http://www.gnu.org | | | | The Metamedia Corporation / HappyMac | | This email address is being protected from spambots. You need JavaScript enabled to view it. | | http://www.happymac.info/ | | | | Based on automysqlbackup script v2.5 | | by This email address is being protected from spambots. You need JavaScript enabled to view it. | | http://sourceforge.net/projects/automysqlbackup/ | | | | enhanced in the autobackupmysql script v1.2 | | by This email address is being protected from spambots. You need JavaScript enabled to view it. | | http://sourceforge.net/projects/autobackupmysql/ | | | +--------------------------------------------------------------------+ Platform detected: linux backupdb Script for MySQL database backup Usage: backupdb [ -c ] : path to conf file [ -m ] : create new sample conf file at path : [ -u ] : mysql db user name [ -p ] : password for mysql db user : [ -h ] : display this help message.
Create a conf file by specifying the path, eg.
[root@oobleck ~]# backupdb -m /etc/backupdb.conf
Open this sample conf file and customize to your needs.
You can run this manually, passing credentials in the invocation, or setup a cron job / service to execute this script daily or hourly, as your needs see fit.