Backup for WordPress MySQL Database on MediaTemple

In preparation for developing my own custom theme, and for good best practice, I have automated a backup of the MySQL database hosting this blog from a Linux host sitting behind a firewall at home. I am using the Open Source SourceForge project, AutoMySQLBackUp. I have been using this Unix shell script at my employer for a long time, and it has occasionally come in handy. As backups tend to do… when you least expect it. With my local copy of the PHP code (or even a fresh copy of WordPress) and my customizations–stored in Subversion–I can recreate this entire site with minimal work.

I have more often used these backups as I intend to now–to recreate the site on a separate host, using the original site as content for testing a new template design.

Using AutoMySQLBackUp is quite easy if you have a Linux host you can run it on. In my case, I copied the script to my personal ‘bin’ directory under my user account–no need for this script to run by anyone other than a normal user–and set the configuration variables inside the script. The variables you needs to set are fully described in the file below the lines where you enter them. So, if you have a question, be sure to scroll down. The items you need to configure are:


USERNAME=username
PASSWORD=password
DBHOST=hostname
DBNAMES="all"
BACKUPDIR="/path/to/backups"
MAILADDR="you@yourdomain.com"

The ‘username’ is a MySQL user with SELECT access to the databases you wish to be backed up. The ‘password’ is the related password for that MySQL account. Note, this account is not the same as a host user account–it is exclusive to the MySQL database to which you are connecting. The ‘hostname’ is the fully qualified hostname of the MySQL host. If you are accessing a database at MediaTemple, this would be the address they assign that is prefixed ‘external-‘. Since you are accessing the site from outside your web server, this is classed as external.

You can explicitly specify the database names for DBNAMES, instead of using ‘all’, but by specifying ‘all’ you will automatically get any new databases that are added in the future. None get missed that way.

The BACKUPDIR is the base directory where you would like your backups store–make sure it is writable by the user running this script. I use a folder in my home directory. The MAILADDR is where you would like result emails sent. There are several options regarding these emails, which are described in the file, however, my preferred means of running this script is from a user crontab file which schedules it to be run nightly as the user. This line:

32 4 * * * /home/localuser/bin/automysqlbackup

will run the script daily at 4:32 am. Saving this line in a file named ‘crontab’, I can load a copy of it to the crontab daemon of the system simply with:

crontab crontab

Crontab will automatically capture the output and mail to the user. You may need to configure an alias if you would like it sent to an off-host address.

There are a few more options in AutoMySQLBackup, but most can be left at the defaults. Review as needed for your purposes.

One note on accessing a MediaTemple MySQL host remotely, you must authorize the IP of the host you will be connecting from to connect to the server in your Account Center Control Panel under Manage Databases, on the Global Settings tab. There is a convenient button for using your current IP. All my hosts at home are behind a firewall, and it is the external IP of that firewall that is really seen, and this button worked nicely for getting the current value. Note, if your IP is not static, or at least reasonably stable, you will be needing to reset this whenever it changes. Watch for an error email from the nightly run, and go update it when you receive one. Be sure to remove the old IP for security purposes.

If you are having trouble getting this functioning, be sure you have the MySQL client libraries installed, and try a manual connection to the database like this:

 mysql -h hostname -u username -p

You will be prompted for the password, and should get a prompt as follows:

Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 2827215 to server version: 4.1.11-Debian_4sarge7
Type 'help;' or 'h' for help. Type 'c' to clear the buffer.
mysql> 

Enter ‘quit’ to disconnect. Any error messages should give you a clue as to what the problem might be. If you can’t connect:

ERROR 2003 (HY000): Can't connect to MySQL server on 'hostname' (111)

Be sure you have access to the server port 3306 (the standard mysql service port) on the host. If you are on MediaTemple, this error can be caused by not having the IP authorized for access as noted above.

Set Your Writing Free with FreeMind

After I closed up shop last night and settled into bed after a long day’s drive, my brain was still running… and it made the connection from HitTail in my last post, to an Open Source project, FreeMind. FreeMind is a mind-mapping application. I was first introduced to these type sof application while persuing my graduate degree in education. At the time we first played with a very old Mac application called HyperCard. The concept was a deck of 3×5 cards with a short subject heading or content description on it. You could freely create independant cards, and then go back and reorganize them into related materials. The goal was to develop a structure for writing a document such as an essay or longer book sized work where you needed to just get a Stream of Consciousness type of thinking going and then be able to go back and organize your writing.

I don’t know about you, but much of my past experience writing was painful. It was oriented around having to write at someone else’s request, on a subject I was probably uninterested in! Anyone remeber their high school or college English courses? While I enjoyed English in general, sometimes the required writing was like pulling teeth–I would put it off until the last minute, and then not have time to do a good re-write. Which I believe all good writing needs, if only to polish up some phrasing here or there.

Writing a blog, the writing often does not get a full rewrite, but I always go back and re-read my work before hitting the ‘Publish’ button. I hardly ever don’t find a little something I want to fix. On a larger scale, I feel a blog needs a focus. I went back and forth with myself trying to define the subject matter I wanted to include here. You may have figured out that my focus is web site management and all the pieces that go into it. Using a tool like FreeMind helps me develop related subject areas to cover. If you are having a problem coming up with and/or organizing your writing, I highly recommend it for getting you going. Of course a blank sheet of paper & a pencil can do the same thing, but the big benefit of FreeMind is that it lets you reorganize when you find something fits better or you need more space. Virtual paper is very big!

Here’s a sample that comes with the program:

[images no longer available.]

Click image for larger view.

Give it a try… it’s free and it might help organize your writing!

HitTail to Save Us from Writer’s Block

I’m writing from the road… on vacation in eastern North Carolina! Been driving most of the day… 🙂

I wanted to point out a very interesting new tool, HitTail, that I came across somewhere–somebody’s blog, but I can’t remember which! I’m going to have to start taking notes… If you haven’t head of the Long Tail by now, you might as well skip reading this article. Just kidding! Keep reading. But, if you have, go read Chris Anderson’s seminal work, The Long Tail: Why the Future of Business Is Selling Less of More.

HitTail takes the concept of the Long Tail and applies it to the keywords used in search engines to find your site. By focusing on the less used terms, and more of them, you can build more traffic because you have less competition. Thus your site shows up closer to the top in the search results. See Vlad’s post, Example of HitTail Effectiveness. Be sure to follow the link back to the original post he has about HitTail.

The reason I’m so excited about it’s possibility, is that it helps me write! It gives me a clue as to what I should be writing about. I can write on most anything, as long as somebody points me in the right (write?) direction! Of course, preferably in my area of expertise. 😉 Vlad said he has been running it about three months and has several hundred suggestions. I’m barely getting any yet… but, I’m just getting started. As the flow chart on the HitTail site shows, I need to get more posts out to ‘seed’ the work. So, here I am writing when I should be sleeping. I’ll probably be up early tomorrow pounding out some words for my readers just to feed HitTail… and you! It’s motivating!

Be sure to checkout the HitTail blog too! Mike Levin really gets around keeping up on the comments in the blog world about HitTail. I expect he’ll even show up here. I’m looking for to the possibilities HitTail will bring.

What’s in a Ping?

While adding the sitemap code to Chasing a Dream, and my old website, I had to consider how the other sites were being notified that it was updated. This is called ‘Pinging’. Using ping-enabled blog software such as WordPress, when you complete a post and publish it, the software notifies other services that you have added a new post. Very simple and straight forward. This allows those sites to give updated sites priority in being updated by search engines for the latest material. Instead of scouring the net for pages, they simply check those sites that advise they have been updated! Very sensible!

You might also see a possibility for misusing this too, by sending pings when your site has not been updated hoping to get preferential treatment by a searching engine. This is called ‘ping spam’ or ‘sping’. Don’t do it! Your site can get dropped or blacklisted by a search engine for sping.

Now, carry this on step further. Sometimes you might link to another blog with a link to one of their posts. WordPress also does what is called ‘pingback’. This is where the other blog site is notified that you have linked to them. This is a special two-way transaction where your site notifies the other, then it verifies that you really have linked to them, then it will post a link back to you, usually including an excerpt of your posting text. I’m sure you have seen these while browsing other blogs. Pingbacks have generally replaced ‘trackbacks’ which were not secure as they did not do this two-way handshake. Pingbacks in WordPress are also automatic–you don’t have to add them to the separate area below the post. In-line entries will do the job.

OK, that’s how it works. What about the question of Who do we Ping? By default, WordPress includes a Ping to Ping-O-Matic. However, it appears that it does not ping Google Blogsearch, so I went on a hunt to see if there were other sites that should also be included when pinging. What I came up with is a Ping List for WordPress compiled by Brandon Hall of the SEO Feed. There are other sources as well, but his posting has a much more current date on it, so I felt it was more reliable. If you are going to compile your own list, be careful about the combinations you choose. You don’t want to include a site that aggregates pings, and pings other sites that you also have on your list–you might get caught for sping!

How well does it work? Well as I stated in my earlier post today, I was able to find one of my own posts from earlier in the day in Google Blogsearch indicating it hand been updated recently as ‘1 hour ago’! That’s what makes a blog aggregator such as Blogsearch powerful. Extremely up-to-date and relevant information.

Additional resources:

Using Sitemaps for Improved SEO

While working on adding more statistic tracking tools to the site yesterday, I was also asking myself the question: How can I get better search engine results? Faster! I know it takes time for new sites to be discovered and included in Google and other search engines, but my domain, cdchase.com, is not new as it has been in use for several years, and has that benefit. However, using Google’s Webmaster Tools, I discovered the site had not been crawled since November! That’s almost five months! I’ve been promoting my 30th class reunion over there, so I need those pages checked more often.

I had played around with sitemaps a little in the past, and knew it had to be the answer. With a blog, we have the benefit of ‘pinging’ other sites when we make a post to advise them that there has been a new entry made. Sitemaps work similarly with the search engines in general, you can add one to your standard website, as well as your blog. Google as well as other sites allow you to submit your sitemap file so you know they have the URLs that you want listed. They get the data they need in a standard format, and we get an easy way to maintain it! Every one wins! The Google Sitemap protocol was eventually adopted by Yahoo! & MSN and Sitemaps.org was created. I expect other search engines will follow.

Adding a sitemap to a WordPress blog is very easy… just use the Sitemaps plugin by Arne Brachhold! This plugin will generate an updated sitemap.xml file in the root folder of your site for the search engines to find–and then tell them it’s been updated! It pings Google, Yahoo! & MSN automatically. You do have to do a little configuration the first time around, making sure the sitemap.xml file in the root folder of your site is writable by WordPress, and acquiring a developer ID from Yahoo! to use their submission API.

If you are using Christine’s Ultimate Tag Warrior, aka UTW, (If you aren’t you should be!) then you will need an add-on to supplement the Sitemap plugin in order to get tags added to your sitemap file. Thankfully, the folks at the Dicontas blog have produced the WordPress Google Sitemap Generator – Ultimate Tag Warrior – Tags Addon Plugin to do just that! While the only trick to this add-on is they say to modify it for your configuration, but then aren’t very clear about exactly what that means. Just to make sure that the ‘add trailing slashes’ option is on for UTW. Here’s what they mean: in their UTWGoogleSitemaps.php file, on line 18 you will see:

$utw_tag = get_bloginfo('url') . '/index.php?tag=' . $utwtag->tag;

If you are using rewrites so your URLs appear like, ‘/tag/some-tag-name/’ for your posts, rather than the default, ‘/index.php?p=some-tag-name’, then you need to update the line above to:

$utw_tag = get_bloginfo('url') . '/tag/' . $utwtag->tag . '/';

Then save and upload as usual for plugins. Run a manual update of your sitemap and it will now include your tags at the end of the file. See an example of my sitemap.xml. Note, to get the ‘pretty’ version of the file you should see from this link, you are really looking at the sitemap.xml file with an XSL stylesheet applied.

If you have a standard web site that could also use the benefit of a sitemap.xml file, there are several different sitemap generators available, as listed at Google Code – Sitemaps page. I chose to use phpSitemapNG. After installing in a protected directory of my web site, and making sure it could write to the root folder, I went through it’s configuration which is mostly defaults, but be sure your host name is specified as you would like it to appear in Google–I’ve gone back & forth between using cdchase.com & www.cdchase.com. When I went to submit the sitemap to Google the first time, I realized I had used www, but had generated the sitemap with just cdchase.com, so it failed. Had to update the config and run it again. You will have th opportunity to update page titles, update frequency & priorities before actually generating the files. For details on these, see the Sitemaps.org Protocol page.

With this tool, and probably most any of them, the sitemap must be manually generated whenever a new page is created. Whereas with the WordPress plugin, it is updated automatically. Want to know how well it works? I made a post earlier today, and was playing with Google Blogsearch, and found my post! It even had a timestamp indicating it’s recency as ‘1 hour ago’! That’s impressive and shows the benefit of sitemaps and pinging on change.

Stay tuned for more on ‘pinging’!

Adding More Statistic Tracking

Yesterday was a busy day working on Chasing a Dream in the background. So busy, I didn’t get to write any posts! I’ll try to make up for that a little today. What I was busy doing was adding some additional web statistic tracking applications and merging old accounts into one at Google Analytics.

After running into one of Darren Rowse’s post at ProBlogger, What Blog Metrics Packages Do You Use? on how he tracks his stats, I decided to try some of his suggestions. It also led to other options too.

I wasn’t interested in SiteMeter, primarily as it required the stats to be public. Once my numbers improve, I’d be happy to share, but I want it to be my choice. See below for more info on my plans to share. I just saw a comment from Michael on Darren’s post telling how you can make SiteMeter stats private… might have to go back and try it! Update: after reviewing the SiteMeter site, I realized this is only for the paid version. We will revisit this in the future.

I’m already using Google Analytics, however I decided to cleanup some of my data last week by putting both my blog.cdchase.com site and my old www.cdchase.com under the same account. I wish I had realized I could have done multiple sites under the same account sooner! It would have saved the need for downloading the data from the old account for archival purposes. Of course, I could go back and login, but it’s not convenient and it’s old data. But, I do want to keep it for long-term analysis. So, I downloaded the data and saved it in an Excel file for archival record and merging & comparison with the new site. For fun, I created a graph of the stats for the period I had which was only since October 2006. (I was going to give you a shot of the graph… but, Excel decided to keep crashing. Maybe later…)

I reviewed the metrics package provided by Media Temple, my host, which is Urchin. If you are not aware, Urchin is the predecessor of Google Analytics, and if you look at both side by side you can see the relationship. However, Google Analytics is much more detailed. So, I’ve decided I can pretty much ignore those stats. Besides, the numbers that I receive from my host are based on the logs which merges all my sites, and Urchin does not give a break down of them by site. On top of that, they seemed really out-of-line with the GA numbers. On the very high side, which would have been nice, but not realistic. I think they are a strictly file-based count, so one hit to a WordPress page gives you all the hits for each include page that is used to construct it. That’s not a realistic way to get numbers today. The JavaScript ‘bug’ that is used for Google and the other systems I installed below are much more reliable. Though you do depend on the user having JavaScript turned on or enabled for the Google Analytics site. (I use the NoScript plug-in for FireFox which disables JavaScript unless I explicitly allow it. I globally allow the Google Analytics servers.) So, those numbers may be on the low side. The other point is how does it track robots since they generally don’t execute javascript… I’ll save that for another post.

While I was there, I did setup my local client to download my raw logs so I can do off-line intensive analysis in the future. This is how I process web logs at the university I work for, using Analog. I have raw logs back over six years! Analog is the creation of Dr. Stephen Turner, the CTO of ClickTracks. Once I achieve a little income from this blog, I will be investing in ClickTracks, which starts at $25/month.

I’ve also added 103Bees… it looks like it will be interesting as well.

Somewhere along the way, I ran into StatCounter and decided to try that too.

I’ll give them all a month to gather some numbers, then give you a recap. I have no intention of keeping them all! I’d go crazy since they don’t always agree with each other. I’ll try to analyze and see which one’s are the most useful as far as a quick overview, and which for a detailed analysis.

As mentioned in a few of the ProBlogger comments, there are also my FeedBurner stats. I’ve been running them from Day 1 too. Subscriber numbers are of extreme importance to a blog when not all visitors actually visit your blog to read it.

As I mentioned above, once I have more significant numbers, I would be willing to share here. I can imagine there might come a time where I might stop doing so for privacy considerations–so my competitors don’t know how good (or bad!) I’m doing. However, I’m generally in favor of transparency, so I will save that evaluation for the future. But, I can say now that I understand other blogger’s choices to both be open with their stats, or not. It’s their choice. And mine. Stay tuned for more details on these packages as the numbers roll in! I will also probably evaluate a few others I was introduced to while reading Darren’s post comments.

Web Site Management Tools & Techniques

I’ve added a new page on web site management tools & techniques that will build a categorical directory of the subjects that need to be covered to properly manage a web site based on best practices. I will be adding to this directory of subject areas with links to my related posts to help keep things organized, as well as to keep an idea pool for future entries.

Please feel free to contribute ideas for related subjects you feel should be included. Thank you!

Web Site Management

In developing a theme for this blog, I have been building around the different technologies & techniques that contribute to best practice web site management. Here I will outline the various areas that need to be addressed when managing a web site, and as I develop posts that address them, I will link to them.

Please feel free to comment and contribute other topical areas of interest that you feel should be covered under this umbrella of web site management.

Domain Names
The name used for a web site as it appears in a browser address. Buying, Selling, and managing.
Domain Name Services (DNS)
The service that translates a domain name & web host name into an IP number in order to be accessible over the Internet. Management, services & doing your own.
Web Hosting
The server that contains the content of a web site. Shared, Dedicated, Managed and Grid.
Email Hosting
Commonly provided with web hosting in order to use the same domain name for email. Same host or dedicated provider. Mailing list management.
Content Management
How content of the site is updated and edited. Static files, blog systems, portals, custom content management systems (CMS).
Site Monitoring
Proving to your clients your reliability requires records and third-party validation. Service monitoring, outage tracking & alerting of problems to responsible staff.
Logging & Statistics
Who is visiting your site. Analysis of your server logs gives a lot of information that is useful to marketers, as well as for optimizing your site.
Search Engine Optimization & Marketing (SEO / SEM)
An amalgamation of the techniques above, including log analysis since that tells you how people are getting to your site & content management since you can optimize your results by how you write your content.

Selling a Domain

No, not this one! But, ChattanoogaCountryHomes.com is for sale.

I’m doing an experiment using Sedo, a domain parking & selling service. I was looking for a means to dispose of ChattanoogaCountryHomes.com, since I’m not actively selling real estate in the Chattanooga area, and I had registered the domain for 5+ years (expires in 2010). I am a licensed real estate agent in Tennessee, but my next venture in real estate will not be here.

After a little research I found Sedo was one of the market leaders in both domain resale & ‘parking for profit.’ I hadn’t thought of doing that in the past, but I had certainly run across pages like that. So, I decided to give it a try. It’s simple as delegating your DNS name servers to point at their servers and filling out some information. They produce an automated page that not only has your offer to sell on it, but related Google Adsense ads that produce income for you as well as Sedo. They also provide domain transfer & escrow services.

If you’ve got a domain you would like to sell, try Sedo… it’s free! You only pay a 10% commission on the sale as long as you park the site with them as well. If you don’t, there is a minimum commission applied of $50.

I’ll post in the future on how my results are. If you have had previous experience selling a domain, with Sedo or someone else, please leave a comment describing your experience.

Search the largest database for used domain names
powered by sedo.com

Managing Your Own Web DNS Services

In one of my first posts I promised to describe how I was able to transfer my domain name from one web host to another with minimal cut-over time, and essentially no waiting for DNS propagation. The key is I did not have to wait for DNS changes to propagate across the Internet at all–the changes only had to occur on my own DNS server. If you were to purchase a new domain name, then you would have propagation delay as the new name is discovered.

I strongly believe in the separation of DNS services and web hosting services. This keeps me from having any issues with my web host holding me ‘hostage’ for some reason because they have control of my domain name. While you may legally own your domain name, unless you manage the DNS services, you don’t have full control. While many web hosts will provide this service to you at no extra cost, I decided long ago I was willing to pay a little more to get those services from a third party to protect myself.

I use the DNS services of Dynamic Network Services, Inc. They are a DNS specialist. They do not provide web hosting services! I initially discovered them while searching for a means of getting a stable DNS name for a dynamic IP assigned by my ISP in order to remotely access a server at home. After I realized all the services they provided, and what insulation it would give me from my web host, I moved management of all my domains there. At the time, they did not do domain registration, and I simply went to my domain registrar and designated the Name Servers hosted by DynDNS as mine. From then on, I used their Custom DNS services to manage my hosts.

While most people might be afraid of managing their own DNS services, DynDNS makes it very simple. Their FAQ pages are extensive and supply all the information you need. I’ve been able to manage all my needs without contacting their support staff, and I’m not a DNS expert–though I try to play one in the movies. 😉 Just kidding!

Back to how I accomplished the move so easy… Since I did not have to add a new domain and change NS records (name server IPs), I only had to add a new host name (blog) to my cdchase.com domain. I will eventually move this site under my main www site, but I have not decided how I’m going to integrate the old content and new. As I’ve stated before, the design is still in Alpha mode–subject to change at any time.

While Media Temple aka (mt) is my host, and they stated that I would not have a dedicated IP for my domain, but that it would be a named virtual host, and they pointed me at the Apache documentation, I knew exactly what I could do! While the IP might not be dedicated to my web hosting server, it does respond to a specific IP, and the name used is what tells it to use one virtual server or another. That IP is what is behind the access domain that they provide–a generic host name that is under their domain control, and you can use at any time–even before DNS propagates if you are stuck waitng for it. By looking up the IP related to it using ‘dig‘ on Linux, I was able to create my A record DNS entry pointing my new host at it’s appropriate IP. Once I did that, it was immediately available!

Why immediately you ask? Because when you provide your browser a a fully qualified domain name like blog.cdchase.com, it has to look up the IP for it. Where it looks is the server that controls the domain above, in this case cdchase.com. Since that domain had been in existence for years, it simply went there, and got the new host IP and I was in business!

Note, as soon as I had the web pages copied to the new site using the generic access domain, and I saw how well things were going, I changed the DNS record for www.cdchase.com. That took up to 12 hours to propagate depending on if you had been to the site before. 12 hours is the TTL or time-to-live setting on my DNS entries, they time out after that time and a client, such as a web browser, will normally re-request them and get the updated IP. Same goes for my MX (mail) entries, 12 hours to time-out and I was in business on my new host. Time now to cancel my old service…

Once you have all the changes you need made, you should test your DNS too… you might want to do it before you change to see how good your web hosting provider’s configuration is! Try DNS Stuff, lots of tools to help testing and trouble shooting.

If I’ve haven’t sold you on the power of separating DNS hosting from web hosting, you can also add on the additional redundancy they provide, distributed world-wide. DynDNS has five DNS hosting facilities spread around the world for redundancy and isolation from network break-downs, as well as improving response times in their related regions. I also use their Mail Hop Outbound service to provide secure outbound SMTP services at home, but more importantly when I’m traveling. If I’m using some hot spot some place, I don’t always have access to their SMTP mail servers information for routing mail, besides the pain it is to find & setup every time. With Mail Hop Outbound, all my mail uses the Mail Hop server. Very convenient and secure. Since I control my DNS, I have also added an SPF record to help support mail security.

If you have specific questions, I would be happy to answer them, just leave a comment! If you are interested in learning more about DNS, get the O’Reilly guide: DNS and BIND (5th Edition) from Amazon.