New AutoMySQLBackup Script

April 19, 2010

(2010/11/04) NEWS: Life has been restored in the source forge project after four years!  A new version 2.5.1-01 has been released.  I am working on merging my modifications with the new code and contacting the developers in the project with the new code.

MySQL Backup Script has been around for a long time.  I have used it on and off for years but now I’ve needed to make some  improvements.   This script is based on VER. 2.6 – Copyright (c) 2002-2003

I have added my own Copyright (c) 2010 – But as the code says:  This program is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

My improvements include:

# VER 2.6 Beta 5 – MTG – (2010-04-18)

#    Added option to archive (rsync) the local backup files to a remote locations

#     using the COPYDIR variable.

#    Added option to copy files into a directory based on the host name using the

#     variable HOSTNAME.  This allows the script to be run from a shared storage directory

#     ( SBM, NFS, NetApp) the data to be kept separate.

#    Added option to additionally backup all database schema only using variable FULLSCHEMA.

#    Added option to backup MySQL configuration file, my.cnf and remove files older then seven

#    days from the BACKUPDIR directory.

#    Added –master-data=2 and –single-transaction to include a comment with the master server’s

#    the binary log coordinates. If used the CHANGE_MASTER_TO line must be uncommitted.

Download it here:

Mark Grennan


tags: , , , ,
posted in Code, Tips & Tricks by mark

Follow comments via the RSS Feed | Leave a comment | Trackback URL

2 Comments to "New AutoMySQLBackup Script"

  1. Jason wrote:

    Nice improvements!

    If I set BYHOSTNAME to yes and COPYDIR to blank, then COPYDIR is wrong set in line 525:

    if [ "${BYHOSTNAME}" = "yes" ];

    I’ll get a copy in /hostname/hostname on the server, that’s not what we expected.

    I guess we have to check COPYDIR is blank or not there:

    if [ "${BYHOSTNAME}" = "yes" ];
    if [ ! $COPYDIR = "" ]; then

  2. Kurt wrote:

    Have been testing this, had to make a few mods;

    The PATH statement needs to be earlier for the all the which commands to work (at least on one of our boxes which has a magical setup) and I had the same issue as Jason , we had left the COPYDIR blank and it still tried to rsync to a non existent directory , the same fix Jason put in sorted it out for us. BTW there is a typo in the fix , should be HOSTNAME not NOSTNAMEA

    Otherwise a very useful script that is much appreciated

Leave Your Comment


Powered by Wordpress and MySQL. Theme by Shlomi Noach,
Creative Commons License
MySQL Fan Boy by Mark Grennan is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.