Menu

Tree [73491d] master /
 History

HTTPS access


File Date Author Commit
 mysqlbackups.d 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 sbin 2014-07-24 JT Moree JT Moree [73491d] reworked makefile to build rpm and moved binari...
 test 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 INSTALL 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 Makefile 2014-07-24 JT Moree JT Moree [73491d] reworked makefile to build rpm and moved binari...
 README 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 TODO 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 mysql_locktables.conf 2014-07-24 JT Moree JT Moree [5cfd58] masked password
 mysqlbackups.conf 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 mysqlbackups.cron 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 mysqlbackups.logrotate 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 mysqlbackups.spec 2014-07-17 JT Moree JT Moree [769ec5] initial commit
 rpmbuild-wrapper 2014-07-24 JT Moree JT Moree [73491d] reworked makefile to build rpm and moved binari...

Read Me

mysqlbackups
============

AUTHOR: JT Moree
COPYRIGHT: Public Domain

INTRODUCTION
------------

This utility will loop over all the files found in /etc/mysqlbackups.d and
process each one as a separate database to be backed up.  The databases
can be on other servers as long as you have the correct authentication
setup in mysql.

BACKUP FILES
------------

The backups will be placed in a configurable directory.  Each host will
have its own directory under that directory.  Files will be created under 
the host directory named after the database and the time of the backup.

BINARY BACKUPS
--------------

As of version .8 there is an option to treat one of the backups in a special
way to allow for rotation and deletion of binary logs.  To use this feature
*) Turn on log-bin in /etc/my.cnf
*) set BINDB=mysql in /etc/mysqlbackups.conf
*) copy EXAMPLE.mysql to /etc/mysqlbackups.d/mysql
*) edit /etc/mysqlbackups.d/mysql to turn on the options
*) enable mysqlbackups-binlogs in /etc/cron.d/mysqlbackups.cron

Assuming you run daily backups: you might want to keep 2 days of binary logs.
If the database is corrupted you can restore from yesterday's full backup then 
replay the binary logs up to some point of the current day.

See mysqldump for more details.

The script mysqlbackups-binlogs will use rsync to copy the logs from where
mysql puts them into the backup directory in a subdirectory called bin.

Ex.  /var/backups/mysql/localhost/bin
     /var/backups/mysql/localhost/mysql
     /var/backups/mysql/localhost/db1
     /var/backups/mysql/localhost/db2

LOGS
----

There is a log file created in /var.  You will want to put the logrotate
script in /etc/logrotate.d/

EXPIRING BACKUPS
----------------

The utility mysqlbackups-expire will walk the backups and delete older backups
based on the settings in the config files.  (KEEPDAYS, KEEPNUMBER)

 WARNING
In the case of putting multiple backups in the same folder (for example, 
dumping individual tables from a database using the TAG parameter in separate 
configs) the expire script may not differentiate between them.  In this case 
you must make certain to only put expiration settings on tagged backups.

I know it's difficult to understand.  I'll rewrite it someday.

CONFIGURATION OPTIONS
---------------------

Global settings can be placed in /etc/mysqlbackups.conf.  Settings for an 
individual backup can be placed in /etc/mysqlbackups.d/<file>.  Most of these are 
easy to understand.  Any global setting can be overridden in an individual backup.

MUSER=mysqluser
PASSWD=foo

HOST=mysqlserver.domain.dom
If no host is given it will try to connect through a local socket.  This is the
default behavior of the mysql client.

DB=database
OPTS="--opt"

TAG="-schema-only"
this option will append a string onto the end of the files that are created.
Use this in the case that you want to backup the same database multiple times.
This is necessary because the backups use the database name.

### MYSQLEXPIRE OPTIONS

KEEPDAYS=
Can be any integer.  Tells the expiration utility to keep backups for this many
days.  Older backups will be deleted.

KEEPNUMBER=
Can be any integer.  Tells the expiration utility to keep this number of 
backups.  Other backups will be deleted.

CRON AND SCHEDULING
-------------------

/etc/cron.d/mysqlbackups contains three lines for services to run.  

The binary log backups are commented out by default.  

The expiration job will expire (delete) backups based on the options set above.  It will delete none if the options are unset.

The backup job looks for all the config files in /etc/mysqlbackups.d and runs a backup for each one.
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.