MySQL backup script

By | 2006/02/18

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).

3 thoughts on “MySQL backup script

  1. WMZ

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

  2. vitaliy

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

Comments are closed.