Monday, December 6, 2010

MySQL Backup Script

This is my almost no configuration needed bash backup script for MySQL. The script first uses the mysql command line application to get a list of every database on your MySQL server, then loops through the list of databases and creates a separate dump file for each database.

You do need to create a ~/.my.cnf for the user the script will be running as.
  1. touch ~/.my.cnf
  2. chmod 600 ~/.my.cnf
The format for .my.cnf should be:

[client]
user = MySQL_User
password = MySQL_Password

Now the backup script. Configure the MYSQLUSER to match the MySQL user you will be backing up using (should match what you configured in .my.cnf.) Change the DIR variable to match where you want database dumps to be stored. Update the paths for MYSQL and MYSQLDUMP if needed. Then schedule the script to run as a daily cron job.
#!/bin/sh
MYSQLUSER=root
DIR=/srv/mysql-backup/dumps
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump

# Day 1 is Monday.
DAY=`date +%u`

# Query MySQL for the list of databases in the MySQL Server.
# Create a seperate dump file for each database.
for DBNAME in $(${MYSQL} --user=${MYSQLUSER} -Bse 'show databases');
do
DUMPFILE=${DIR}/${DBNAME}/${DBNAME}_DAY${DAY}.sql
# Make the directory structure if needed.
/bin/mkdir -p ${DIR}/${DBNAME}
${MYSQLDUMP} --add-drop-table ${DBNAME} --user=${MYSQLUSER} > ${DUMPFILE}
# Remove last weeks backup if it exists.
if [ -e ${DUMPFILE}.bz2 ]
then
/bin/rm ${DUMPFILE}.bz2
fi
# Compress the dumpfile using bzip2.
/bin/bzip2 ${DUMPFILE}
done
# End Loop
This script will create a seven day rotation of MySQL dumps. (One dump for each day of the week.) The script alone isn't a complete backup solution. Use your backup solution of choice to backup the dump files to tape or other media. I'm using CrashPlan for all of my personal backup needs.

Sunday, August 1, 2010

StarCraft II Digital Download Mac Install Bug

Up until now I've kept gaming out of this blog. It's supposed to be a blog about aspects of being an IT Professional, but every now and that one needs a diversion. Anyway...

Yes I purchased StarCraft II, but not on release day, and I didn't pre-order. I did go for the digital download option. After waiting something like 12 hours when I tried to install this on my MacBook Pro I was met with an error message: "Please Insert DVD named StartCraft II Disc." There was no way to get past this error. it was a digital download, there is no DVD media involved here.

The ultimate solution was to create a disk image named "StarCraft II Disc" using disk utility. Select the 8.3 GB (DVD+R DL) option in Disk Utility for this. The installer takes up 7.53 GB. Once the disk image is created, move or copy in the downloaded install files and run the installer from the disk image. The install then works as expected.

My question for Blizzard is do they really expect normal computer users to be able to understand/do this or am I just running into a bug in the digital download? Maybe I'll find out when their swamped support staff get around to my email.

Thursday, June 17, 2010

iPhone 4 Ordered!

Spent the past week trying to figure out why in the world I qualify for a new iPhone 4 at the full AT&T subsidized price when I just got my iPhone 3G S last year around May. My coworker who got his iPhone 3G S before I did last year didn't qualify. Today I finally figured it out.

  • March 2008: Wife's Motorola Razr falls out of her pocket and into hot tub. We dry out the phone and it works.
  • April 2008: Wife's phone won't charge. We deal with it by swapping batteries as we both have Motorola Razrs.
  • May 2008: Wife's phone fails completely due to water damage. We're able to get a new phone at a discount (not full subsidized price, but better than full price) by renewing our contract for another two years.
  • May 2009: I'm eligible to get subsidized price for iPhone 3G S and upgrade.
  • June 2010: 2-year contract with AT&T signed in May 2008 is up, and wife has had her phone for 2 years, making both phone numbers eligible for upgrade.
So I promised my wife a new iPhone for as a graduation gift (she finished grad school in May.) So I tried pre-ordering her phone on June 15th. It would just not go through. Tried again on the 16th with the same results, but I was able to get my new iPhone ordered. Tried again to order my wife's phone on the 17th and yay the order went through so both of us will have iPhone 4s soon! Just not on June 24th, so I'll have to go without for a week or so in order to sell my iPhone 3G S via Gazelle.

Timing is everything, though I never figured a water damaged phone would somehow work to our advantage.

Monday, June 7, 2010

iPhone 4 Announced

Apple announced iPhone 4 today at WWDC. One of the most interesting bits is that AT&T is offering full subsidized price ($199 for 16 GB, $299 for 32 GB) to anyone who's contract is up in 2010. On a whim I checked, and yup I'm eligible. Cool, but I don't have $299 for an upgrade.

I previously heard about Gazelle.com on one podcast or another on Leo Laporte's TWiT Network. Gazelle.com is an online service where you can sell your used gadgets for cash. I checked it out. My iPhone has spent most of it's life in an iFrogz case, so it looks perfect to my eyes. Gazelle's offer for a good condition iPhone 3GS 32 GB is $274, and $304 for a perfect condition. The offer is good for 30 days, so if you sign up today and get your iPhone back to Gazelle by July 7th, 2010 you're good to go.

So I'm going for it. Will let you know how it goes as things progress.

Monday, February 1, 2010

ThinkGeek’s Phantom Keystroker

ThinkGeek’s Phantom Keystroker V2 is intended to be a practical joke to play on unsuspecting friends, family, coworkers. The USB device is the size of a flash drive. When connected to a computer it emulates a keyboard and mouse and periodically toggles caps lock, types random text, or wiggles the mouse.

There is plenty of potential for pranks here, but there is also potential for use in the real IT world. For example, it may be policy to require use of screen lock on idle to satisfy a policy such as PCI. Corporate administrators might enforce this on Windows clients using Group Policy. In the IT support role, it may be necessary to be logged in as the user the computer is assigned to in order to configure/fix something for that user. User’s seem to have a magical ability to vanish into thin air when they are needed by IT Support to resolve their problem.

For example, you have to copy a large file to the user’s laptop. You inform the user that this is going to take about half an hour, and the the user vanishes into the ether. Having no shortage of things to do, you return to your desk to take care of other trouble tickets while files are copying. You return 20 minutes later to find the screen locked and the user has gone to lunch.

Enter the Phantom Keystroker. Before you and the user walk away, plug in this device and set it to periodically wiggle the mouse. The mouse movements prevent the Windows screen lock from kicking in, and IT Support can finish up without tracking down the user or asking the user for their password. You could also use it to wiggle your mouse while watching a DVD or giving a PowerPoint presentation to prevent the screen from dimming or the screen saver from kicking in.