• Home
  • About Me
  • Contact
  • Things to do Before I Turn 30

the bofe blog

a twenty something IT professional with a few things to say

Feeds:
Posts
Comments

Showdown: MySQL vs. SQL Server 2005 (Backups Edition)

March 12, 2008 by bofe

My disaster recovery needs from a database standpoint:

  1. Ability to restore to a point in time
  2. Retention period of 4 weeks
  3. E-mail notification on failure

MySQL Backups

A basic cron job dumping your databases on a daily basis:

shell> crontab -e

Add this to your crontab:


0 2 * * * mysqldump -ubackup_user -ppasswordhere --all-databases | gzip -c > /path/to/mysql_backups/backup_`date +%Y-%m-%d`.sql.gz

This will run at 2:00 AM daily and back up all of your databases. It will produce a fancy .sql.gz file that has a date stamp. Example: backup_2008-03-12.sql.gz. For generating Cron jobs, look at this site.

This is nice, but you’ll have to pay attention to your backup folder because eventually you will run out of disk space. You will not receive any notification when the backups fail or when you run out of disk space from this method. You also see that it gives anyone who has access to your crontab access to your password. Make sure this is a database user that has READ ONLY access to all dbs/tables.

SQL Server 2005 Backups

Some will say I’m a little biased… but this is one of the parts of SQL Server that makes it worth the price. If an image is blurry in the display, click it for full resolution.

  1. Create a new Maintenance plan
  2. Click ‘Back Up Database’ on the toolbox.
    toolbox.png
  3. Drag to the blank window.
  4. Select your databases, and various options for your backups. I recommend using ‘verify backup integrity’ and having your .bak files moved off site.
    ss-maintplanoptions.png
  5. Schedule your maintenance plan.
    schedule.png
  6. Add a notify operator task (you must have Database Mail Configured) , and drag the red node to it. This will email your specified operator (I get them sent to my phone) when a backup fails.
  7. Clean up! I do separate a weekly data cleanup maintenance plan to check my indexes, delete my backups older than a month, and lots of other things. Here’s a screenshot:
    ss-maintplan-extended.png

Clearly, SQL Server 2005 meets and exceeds my disaster recovery needs over MySQL. Did I mention it was extremely easy to set up in SQL Server Management Studio?

I didn’t have to research bash datestamps or find a site to generate crontabs.

Tim suggests I use this perl script for deleting old MySQL backups (run at the same interval as the backups):


#!/usr/bin/perl
use File::Find;
my $path = shift;
my $threshold = 60*60*24*28;
find(sub { /mysqlbackup\.tar\.gz$/i and
unlink "$_" and
print "$File::Find::name deleted\n\n" and
(( ((stat($_))[9] ) + $threshold) > time);
}, $path);

Also from the comments:

find /path/to/mysql_backups/ -type f -mtime +N -exec rm -rf {} \;

USE AT YOUR OWN RISK.


Possibly related posts: (automatically generated)

  • Re: Is SQL Server ‘keeping up’ with MySQL?
  • Apparently Microsoft doesn’t dig Nietzsche (or MySQL does)
  • Guide to Backing up your Virtual Machines with VMware Consolidated Backup (…
  • SQL Server Administration Best Practices

Posted in Personal | Tagged comparison, dba, mysql, sqlserver2005 | 4 Comments

4 Responses

  1. on March 13, 2008 at 14:31 dmac

    If you want to automatically purge old MySQL backups based on being N days old you can just slap your dump command into shell script with the following command. Then schedule the shell script via cron.

    find /Your_backup/directory -type f -mtime +N -exec rm -rf {} \;

    Replace N with the number of days you want to keep on hand. This command uses the timestamps on the file to determine whether or not to delete it.


  2. on March 15, 2008 at 16:50 deStone

    Uh, microsoft cronnie.


  3. on October 13, 2008 at 16:37 meregistered

    Hello have you considered using the MySQL UI tools?

    That would be a more likely comparison. And just easy although maybe not as many options.


  4. on October 14, 2008 at 17:20 bofe

    @meregistered You’re right. I’ve always had problems with MySQL’s GUI tools… particularly not wanting to run them on localhost.

    The only feature that I see missing from MySQL GUI tools is the ability to clean out your backups on a regular basis.



Comments are closed.

  • Pages

    • About Me
    • Contact
    • Things to do Before I Turn 30
  • Recent Comments

    • Some Betty on Why the hate?
    • stinkypie on Why the hate?
    • stinkypie on Why the hate?
    • JohnO on Why the hate?
    • Yee on a pancake on Why the hate?
    • adam on Why the hate?
    • JohnO on Why the hate?
    • deezil on Why the hate?
    • Yee on a pancake on Why the hate?
    • Dave on Why the hate?
  • Recently Popular

    • Guide to Backing up your Virtual Machines with VMware Consolidated Backup (VCB)
    • Sync Google Calendar and Facebook Events
    • How to Use Excel 2007 and Goal Seek to calculate what the minimum grade you need on a final exam
    • VMware Consolidated Backup: Explained
    • Firefox 3 Constantly Crashes -- advice?
    • modifying osCommerce - [part 2 - Functions, Cases, Blocks Oh My]
    • Problem with Orphaned Users/Logins in SQL Server 2005 Migration
    • Facebook 12 Step Program
    • Sortables with Scriptaculous, PHP, and MySQL in 6 Easy Steps
    • point(x,y) versus point(lat, long) or What I Learned Today
  • Archives

  • Tags

    4815162342 advertising ajax apple bofehax byebye css dba delicious links development drm facebook finance firefox Geek gis Google imadork linux mememe Meta metoo money murray Music mysql owensboro Personal personal finance personalfinance philosophy php rss scriptaculous sqlserver sqlserver2005 Tablet PC Uncategorized vmware web Weblogs Web Standards whitewhine work wtf
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com

Blog at WordPress.com.

Theme: Mistylook by Sadish.