Create MySQL Backup

There are a number of ways to backup a MySQL database. For my local environment I like a quick way to take a backup before trying something new. Rather than go through the cumbersome process of logging into Terminal, navigating to the MAMP /bin directory and then entering a very long command, which I would easily forget, it’s simpler to create a shell script and then invoke it as an Application by using AppleScript.

First, create your shell script by opening a text editor, eg TextWrangler (and not an RTF editor), and type:

#!/bin/bash

On the next line type in the commands you would normally do in Terminal. In my case, I wanted to navigate to the MAMP /bin where mysqldump lives. Then, I wanted to use this to dump a sql file of a specific database within my sites directory.

cd /Applications/MAMP/Library/bin/
./mysqldump -a -uroot -pPASSWORD mydb1 > ../../../../Users/[username]/Sites/Backups/db1.sql;

Finally, close it with

exit

You then save this in a logical place (ie somewhere you can find it!), in my case /Users/[username]/Sites/Backups/scripts/. Next go to Application > Utilities and launch AppeScript Editor. Type the following into the edit pane.

do shell script "/Users/[username]/Sites/Backups/scripts/backup_nsdaukcom_263323_db1.sh"

Save this to either Applications or a sub-directory within Applications. When you change the File Format to Applications before saving.

Once done, all you need to do to take a backup is double-click the new application you’ve created and your previous backup is overwritten with a new one.

Installing Windows 7 on a Mac with Snow Leopard and Boot Camp

After a few months of waiting my copy of Windows 7 finally arrived in its shiny new box with the rounded corner yesterday morning. Since then it’s been sitting on the table waiting for me to get round to installing it onto the Mac Book Pro, which has been quivering in the corner for some time now. Last night was the backup. I’ve opted to use an ethernet connection from my MBP to my Powerbook, which serves as my backup destination these days.

With that done and my data safe it’s time for my MBP to get used to sharing.

10:20pm
I find Boot Camp Assistant, crank it up and partition my hard drive giving a healthy 48GB. This is so much easier than the toil I went through partitioning my PC when I installed XP. Thank you Apple.

10:22pm
It takes a little time to create the partition. Once done, I insert the Windows 7 CD and click Start installation.

10:23pm
My MBP reboots off the CD and I get to select my language options. After selecting them I choose the partition created by bootcamp – the one with BOOTCAMP in the title – and click Format. I was hoping to be able to select FAT32 so that I could share files with the MacHD but W7 doesn’t give you the option and automatically formats it as NTFS. Looks like VMWare Fusion is needed at some point.

10.25pm
After accepting the licence we’re away and Windows 7 starts its installation with the Install Windows dialog. First it copies the Windows files, then expands them before installing features and updates. Time for a cuppa.

10:33pm
The first of the system reboots happens. A message appears saying Starting windows services before the Install Windows dialog appears again.

10:37pm
The screen flckers black and then reappears again. This is presumably some kind of refresh that has to happen. The installation is now two-thirds complete with the green bar gradually extending to the right across the bottom of the screen.

10:39pm
A message appears saying setup will continue after the computer restarts. Predictably, the computer restarts. Ah! The chimes – some semblance of the Mac is still there. I can’t remember who produced the Windows’ notes but it doesn’t compare. I seem to remember it was a famous composer who had to do it and supplied over 100 versions to Microsoft back in the ’90s. Anyway, onwards …

10:40pm
Okay, things are happening. It’s setting up Windows for first use and checking video performance. And a (low res) dialog to enter my username and computer name. Remember to use a mouse with your MBP at this point as it’s far easier to navigate the screen due to the trackpad drivers not being installed yet.

10:42pm
It’s time to set up the password. Unlike Macs you’re forced to do this. It’s no bad thing but it would be nice to be trusted to make this kind of decision yourself. After all, I did pay good money for it. Moving on, I get the product key message next. After hunting around I find it on the inside of the plastic container W7 came in. It takes two attempts to get it right as normal with Windows product keys but then it’s off authenticating its authenticity before coming back with three options:

  • Use recommended settings
  • Install important updates
  • Ask me later

I’m tempted to take the Ask me later until I remember this is Windows so I plump for the max option and click Use recommended settings. Better safe than sorry. The time zone window appears so I leave that as it is. It’s automatically worked out where I am.

10:47pm
Next up is the wireless network. Mine appears so I click that and while performing living room gymnastics I copy the key on the underside of my router into the Security Key field. Getting it right first time is a relief as my back is starting to seize up. I then get three choices on the next page:

  • Home network
  • Work network
  • Public network

Home network it is …

… it’s thinking and connecting …

… and now finalising settings …

… and done.

10:49pm
The welcome message appears and now my desktop is being prepared for me. How sweet of it to let me know. Whoah! A huge MS icon in the middle of my screen appears like a hive of giant bees just smelled the honey I stole from them earlier today. Must sort that out soon before they get to close.

What to do next though – that’s the question. Referring to my SimpleHelp.net guide I realise I’m on a slightly different path to theirs.

10:51pm
Okay, time to use my intuition so I do a Windows Update and see if that sorts out the drivers. Start > Programs > Windows Update and I’m in a new place where it tells me there are 8 important updates. I add the IE8 one mysteriously not selected and go for the Install button. Yes, I accept the Windows Malicious Software tool. And download begins. What’s on TV … [reaches for the remote]

10:56pm
Updates done, time to restart. Chimes again – ah … and we’re off again. 20 seconds later W7 starts up and begins confuguring the updates.

10:58pm
Time to log in for the first time. And I’m in again. What next? Time to take a look at the resolution I think as it’s driving me mad – those bees are getting too damn close! Yes, right-click is still there with a direct link to screen resolution. I up it to 1440 x 900 and the bees retire into the distance.

11:00pm
Back to the SimpleHelp.net guide where in step 17 it mentions what to do if there are no sounds, something I’d been blissfully unaware of. So the next thing to do (after disabling wireless due to not having any security on the MBP for W7 at the moment) is to replace the W7 CD with my Snow Leopard one. But the eject button isn’t working yet so into Windows Explorer I go and right-click the W7 CD to eject it. This is why you need to use a mouse. In goes the SL CD.

11:04pm
The new style autoplay dialog pops up so I get to click a Run setup.exe rather than search for it in the folder. Yes, I do want to allow the following program to make changes tho this computer seeing as I put the CD into the computer in the first place – trust me, please Windows. I know what I’m doing. Kind of.

11:06pm
Here’s Boot Camp. I accept the license agreement and then click Install the Apple software update for windows. More waiting as this is installed.

While that’s going on I get to watch a bit of Nick ‘BNP’ Griffin in the Question Time bearpit. Hmm. Nope, I don’t think I’ll be voting for him in the next general election. Liberal Democrat all the way, me. Don’t knock them, they’re the only party to actually understand the current financial crisis. Admittedly, their leader looks like he’s just left school but I won’t hold that against him!

How’s the installation doing? Installing Sigmatel Audio … never heard of that one. Now on realtek Audio. Presumably, we’re nearly there as it seems to be alphabetical. Ah, no, cirrus radio is next. Oh well. Trackpad drivers – hooray! That’s going to make life easier though I imagine it won’t have the three and four finger gestures available. And no pinching either – boo!

11:14pm
It’s done and Boot Camp is as well. I click Finish and then Restart. This time when I hold the option key down during the restart I get to see my two partitions. I can go to eiether Mac OS X or W7. Cool.

And that’s in. All in all it took 55 minutes and was pretty painless. The Windows update and Snow Leopard driver update were the main bits that might throw you but the rest was straightforward. Now for the new Aero themes, sounds, loading software, sorting out the trackpad (see the bootcamp control panel – bottom right icon) … oh and to disable the automatic wireless connection as I need some antivirus protection. Norton dual looks good though it isn’t ready yet.

This is purely my experience and while you’re welcome to follow the same road I took I should just out that I’m not responsible for any mishaps you meet on the way though am more than happy to help out if you’re struggling. Be warned though, I may well say ‘Er … don’t know!’ Before doing anything like this always make sure you’ve got a backup and have the OS disks you need and can connect to the internet for the windows updates. Also, check to see that your system meets the requirements specified by the software you’re installing.

Good luck! I’m off to play with software I haven’t used for a year or two …