Home > Linux > MySQL backup script

MySQL backup script

I’ve put together a MySQL backup script for use on this server. I thought someone else might appreciate use of it (or just use as a basic template). You’re welcome to download a copy (see Downloads). Basically it does this:

  • Outputs a list of databases
  • using mysqldump drops these thru a bzip2 filter for compression and stores in /$dest/ by date.
  • using mysqldump –host drops these directly into a remote machine mySQL server.
  • Deletes dumps older than 7 days
  • rsync all dumps to remote machine for remote archiving. (note: currently rsync is NOT set to erase older than 7 days from remote machine.)

Instructions for personal automated setup are included in the script. Let me know if you have any problems with it.

known bugs:

This does not yet dump into a remote machine if the database does not yet exist. Each database must be created manually the first time (looking into a fix).
Rsync does not remove older than 7 days from remote machine. Still deciding whether this is a feature (more history on remote machine) or bug (fill up disk space).

Categories: Linux Tags:
  1. June 24th, 2008 at 19:45 | #1

    i don’t see downloads link on this page :
    http://ubuntu-tutorials.com/2006/02/18/mysql-backup-script/

    I am trying to write a sample script to backup mysql db

  2. June 10th, 2009 at 20:47 | #2

    It would be great to add email feature to the script.

  3. March 4th, 2011 at 01:16 | #3

    I looking for backup script to mysql db, which will create backup on second mounted partition?

  1. No trackbacks yet.