‘Maintenance’ Pages via Apache mod_rewrite

Posted on November 30th, 2008 in General,Linux System Administration,Programming by Brandon

Occasionally, I’ve found it useful to put up a maintenance page while performing some work on a website. It may be useful if you are debugging and want to ensure that regular visitors don’t see any application generated error messages or blank pages or anything.

This method uses mod_rewrite to redirect all requests to a maintenance page that you create. Since

First create maint.html with some message that you want to display to your users. Then add this to your Apache configuration to redirect users to that page. Obviously, you’ll need to substitute your own IP address. You can add multiple lines to include multiple users if necessary. The configuration essentially says requests not from your IP (notice the exclamation point) will be redirected to /maint.html and that is the last Rewrite rule that should be followed.

  ##### Maintenance section
  ## Uncomment and add your IP address for performing maintenance
  ## Add multiple addresses on multiple lines if necessary
  RewriteCond %{REMOTE_ADDR} !^11\.22\.33\.44$
  RewriteCond %{REMOTE_ADDR} !^1\.1\.1\.1$
  RewriteRule . /maint.html [L]
  ##### End Maintenance section

ddrescue Saves the Day

Posted on November 12th, 2008 in Data Recovery,General,Linux System Administration by Brandon

I had a very bad thing happen to my regular work PC last week.   I use a Windows PC for my normal desktop machine, and when I turned it on one morning is refused to boot up.   After several attempts, it became obvious that the hard drive was dying and wouldn’t last much longer.   I have most of my irreplaceable files backed up to Amazon S3 via JungleDisk, but it is still a huge pain to try and reinstall an operating system, all of my applications, and try to get back to a working system

Fortunately, at a recent CALUG meeting, we had Barry Grundy give a presentation on Data Recovery.   Barry is the author of LinuxLEO – a pretty comprehensive document about Data Forensics  using open-source tools.  In his presentation he covered a number of open-source tools that are super-useful for recovering raw data and then in making sense of it.    The main tool that I found useful was GNU ddrescue which is a variant of dd specifically created to retrieve as much data as possible from a failing drive.’

ddrescue works by reading data from the drive.  When it encounters a bad sector it skips forward a ways and tries to read again.   If it is unsuccessful, it skips forward a larger amount and continues until it is able to read something successfully.  That process repeats until it has gone through the whole drive.    This retrieves as much good data from the drive as possible.   You can then run it again with some different parameters to go back and retry those error areas to retrieve all of the questionable areas.

The drive that I had failing was a 160 GB SATA drive that was over 4 years old.   The first round with ddrescue looked pretty bad – it had around 25% of the drive was bad or questionable.  After some experimenting to figure out the ideal parameters and a few passes through the entire drive I ended up recovering my entire drive minus just 110kb of bad sectors.

At that point I had almost all of my data, but I wasn’t able to boot off of the drive.  There were some problems with the master boot record and the NTFS volume was corrupt and wouldn’t mount cleanly.  I ended up attaching the drive to a working machine so that I could run chkdsk on it which solved the NTFS corruption problems.   I had to work around quite a few problems, but eventually was able to restore it to a point where I was able to boot just fine.

Jungle Disk Error getTotalSizeByType DB error (11)

Posted on November 10th, 2008 in General by Brandon

My hard drive recently died and I was able to restore most of the files without any incident. However, it seems that some of my cached JungleDisk data became corrupted. When trying to connect to a bucket, it generated this error:

getTotalSizeByType DB error (11) database disk image is malformed

Some quick google queries identified this is an SQLite error, but didn’t provide any method for fixing it. Removing and re-adding the bucket to the JungleDisk configuration didn’t resolve it.

To finally get it fixed, I just cleaned out the JD Cache manually. The cache directory is configurable from the JungleDisk Settings menu under "Application Settings" On a Windows machine, it is likely in C:\Documents and Settings\<Your Username>\Application Data\JungleDisk\cache. That directory contains sub directories for each bucket that you connect to. I closed JungleDisk, then simply deleted the cache directory for the bucket that was having the problem. Then when restarting JungleDisk back up, I was able to re-add the bucket and it recreated the cache and went on to work fine.

ClassPerformance.com Is Now Live

Posted on November 9th, 2008 in General by Brandon

I’ve spent the last little while working on ClassPerformance.com The site is for Brad Cohen who has Tourette’s Syndrome and has gone on to become an award-winning teacher, a motivational speaker, and author.  He has appeared on shows such as Oprah.   His life story has been made into a Hallmark Hall of Fame movie.  It will air on CBS on December 7th.  The website revamp is in anticipation of a spike of traffic around the time of the premier.

The blog, and most of the content for the site is through WordPress.   I wrote some additional custom functionality for the dynamic content, and integrated the HTML template.   Overall, I’m quite pleased with the result and am looking forward to the movie.