Quick and Dirty MySQL Backup Script

by damonp on March 14, 2007

in Sites,SQL,SysAdmin

I previously posted a Quick and Dirty MySQL Backup snippet that has gotten a bit of traffic. It works well in a pinch, but it doesn’t have any features. I use it primarily as a safety backup when performing maintenance on a MySQL server.

Several of my clients have requested a script that they can use to do on demand one-off backups. I rolled the snippet up into a very quick-and-dirty MySQL backup.

Download mysql_quick_back.sh

Installation

  1. Copy mysql_quick_back.sh to a directory in your path (~/bin/ for me).
  2. Set execute bits with
    chmod 755 mysql_quick_back.sh
  3. Set MySQL user/pass, directory to save backups to and notification email in script configuration
    # START configure
    # MySQL user, needs SELECT privileges
    # Create a new user with these permissions!  More secure than using a user
    # with full permissions
    user=

    # MySQL password
    pass=

    # admin email address
    adminemail=

    # backup location without trailing slash
    # set to current directory
    backuppath=.
    # or set to your home directory
    #backuppath=/home/admin/db_backs

Usage

Simply execute the script

NOTE

For a full MySQL backup application, check out the original MySQL Backup by Peter Falkenberg Brown. MySQL Backup is robust enough to use as a daily backup. I use it on most of the servers I manage.

Popularity: 1%

Most Popular Posts

Damon Parker is a freelance sysadmin and web developer in Texas. He specializes in server setup, server security and high performance server configurations. Need help setting up a web server or getting a server back online after a crash or hack? Email Damon

Leave a Comment

Previous post:

Next post: