Backing up a MySQL Database

Archive for the ‘Techy’ Category

|

Backing up a MySQL Database

Thursday, January 22nd, 2009

A couple of our hosting customers recently posted on Twitter that they were looking for a solution to backup their MySQL databases. This is an excellent idea and is highly recommended. With the following script we'll provide, you will have the capability backup one or more MySQL databases to either your FTP account or an email address.

  1. You will need to log into your cPanel account and create a new email address with the username of "backups" so that you have an email to send your DB backups to.
  2. While still in cPanel, go to your MySQL section and create a new database user. Attach that user to the database you want to backup.
  3. Open up your favorite FTP client and sign into your hosting account.
  4. While in your root directory (before public_htmll, create a new directory titled "backups" and then navigate to it.
  5. Download the file db_backup.php, and then open it in a code editor.
  6. Find line 33-34; This is where you will enter in the details for the database that you want to backup.
  7. Find line 27 & 45. Where you see "cpuser" enter in your cPanel username.
  8. If you want the backup sent to your email address, find lines 47-49, and fill out appropriately.
  9. If you want the backup uploaded via FTP, find lines 57-61, and like the email portion, fill it out appropriately.
  10. Once you've made those edits, save and then upload to the /backups/ directory you created. CHMOD the file to 644.

Hopefully you're not too tired just yet! So far we've created a directory that is outside of your web directory, so that your backup script can sit comfortably. You've also added in the details for the database you want to backup, what email you want it sent to, and if you want it backed up to another (or the same) FTP account.

The next thing we're going to do is set up a cron job. This essentially is going to automate the process of backing up your database to the schedule you set for it. So you'll be able to let it sit without having to worry about manually backing things up yourself. Find line 27, and copy the snippet that looks like this:

php /home/cpuser/backups/backup.php > /home/cpuser/backups/backup.log

Navigate to the Advanced tab in cPanel, and then click on Cron Jobs. You'll see two different options to chose from, but you can go ahead and select Standard. Now you're going to take the line 27 we copied, and paste that into the "Command to run:" input box. Now we have the choice of setting up the schedule for the cron job to run. I recommend leaving the settings at default. As it is right now the cron job will run a backup every month, every day at 3am. Of course you can change any of those options, but I would not backup more than every day. You don't need backups every minute! Also, at the top it gives you an option to add an email so you can receive an email about the output; Leave that blank. We're already going to be receiving a daily email with your backup, so this isn't necessary.

So, go ahead and save your cron job. Now you've got a backup system set in place for your database :).

Tags: , ,
Posted in Techy | No Comments »

Need some Christmas List Ideas?

Thursday, December 11th, 2008

With Christmas just a mere 13 days away, it's time to start finishing off those Christmas lists! We're here to go ahead and give you some ideas of gifts to get for others, or yourself. We know that some of you opt for the cash/gift cards so you can get what you want... Now it's just a matter of figuring out what that's going to be!

Computer Periphials

intp-hero The Black Magic Intensity Capture Card is perfect for individuals that have always wanted to get into capturing but just didn't know what card to get. Not only is this card perfect if you want to capture in HD, but now you can also use your HDTV with it, or maybe even skip that DVI on your 24" HDMI Widescreen LCD so you an experience HD in all its glory. This card is also perfect for those that perhaps want to capture their gameplay from Halo 3 or COD5.

20-231-145-03 Do you run Firefox, Photoshop CS3, an IM client, and other programs all at once? If you are I'm sure you're starting to notice that you're running out of RAM and things are slowing down. Well, if that's the case then I think it's time you upgrade that RAM! Newegg constantly has great deals on RAM, and currently has G.SKILL 2x2GB DDR on sale for $44.99. If you're not what kind of RAM you need, install CPUID which can give you a detailed spec report of your computer.

31us7cxpzl_ss400_ Another perfect addition is always adding on extra hard drive space. If you're not savvy or comfortable with adding another hard drive, no worries! An external drive is just as functional as your internal drive--just easier to setup and portable! Amazon currently has the Seagate FreeAgent 500GB External Hard drive for $79.99, as it has $50 off! :) If you've got an Apple computer with Leopard, now you can take advantage of setting up and utilizing Time Machine!

Gaming

935846_80519_front If you played on a Nintendo 64 years ago, you may have played Banjo-Kazooie. Well, almost a decade later and we've got a new release from the lovable bear and that every so annoying bird: Banjo-Kazooie: Nuts and Bolts. In this new release we've reintroduced to Gruntilda the evil Witch, and a new evil, the Lord of the Games. Complete all the challenges from LOG to win the the right to being the rightful owner of Spiral Mountain.

78-112-002-02 A necessity for almost all Wii owners should be a wireless motion sensor bar. NYKO Wireless Sensor Bar runs $15.99 through Newegg and currently has excellent customer reviews. No more having to worry about the wire hanging off from the side of your tv, or moving your Wii around only to forget your sensor bar is still hooked in, and having it fly behind your tv. This is also perfect for those of you that take your Wii with to a friends house to get everyone involved. Less wires to deal with makes it easier to travel with it!

74-502-001-02 If you're big into playing on Xbox Live with games like Halo 3 or COD5, you know that one of the key ingredients to good teamwork can be communication. So replace your Xbox headset with the Turtlebeach Ear Force X1 [wired] Headset.No relying on batteries, as it plugs directly into your 360's USB port. The headset features comfortable ear padding, as well as a volume control. Quality on the mic is decent, with minimal background noise. The wired headset is $49.99 or you can opt for the wireless pair running at $97.99.

Just Cause

zebra If you don't need any new techy gadgets in your list, how about some awesome t-shirts? Threadless is home to user-created designs ranging from cute and cuddly, to dark and gloomy. T-shirts can range from $5, $10, $15 or $25 depending on the sale and if the shirt is a new release. Take advantage of their points system which can earn you free swag. Pictures of yourself can earn points, as will referring new sales to them. So what are you waiting for, Race your stripes off.

acda_r2_fish_training_school Don't have room for a pet, or can't get one? No need, because now you can get a goldfish and train your goldfish to play football, basketball, swim through hoops, and zig-zag around poles. ThinkGeek has come up with an amazing training kit that will seriously train your fish to do that. Now you have no reason to be lonely because you don't have any pets! And besides, how many people do you know that have a goldfish that can do more neat tricks than their dog?

polyvinylwall2 Looking to spice up your room a little bit? Or are you not able to paint in your apartment or dorm? No need to have a boring room, so check out Blik's wall decals. You just peel them off, and stick them anywhere you want them, be it a bathroom, kitchen, or bedroom. They've got a variety of decals to chose from (some are from Threadless designs!) to spice your any room in your place. My favorites are the Pug family and the Fake Pandas Have More Fun.

Readers: What Christmas list ideas do you have that you'd like to share?

Tags: , ,
Posted in Techy | No Comments »

|