Software dev, tech, mind hacks and the occasional personal bit

Author: James Page 13 of 20

Automating MySQL Database Backups

Great, so you’ve got your web application up and running on some server somewhere, and thousands of users are hard at work entering their valuable data into your application, and thence to a MySQL database. Now people depend on your system to keep their data safe. What are you going to do about it?

The approach I’ve taken is to run a backup script on a cron job, which dumps data from the database a few times a daily, compresses it, and emails it off to my GMail account. All those GMail gigabytes have got to be good for something, right :-)?

I started writing a simple backup shell script using mysqldump, gzip and sendmail, but ran into problems on RailsPlayground as sendmail is not supported there. RailsPlayground suggested this perl script for mysql backup (mirrored on my server). The script does pretty much what I was looking for, and also supports skipping tables (useful for ignoring things like session tables, which, for my app, are not really worth backing up).

A little more investigation revealed that the script wouldn’t work out of the box, as RailsPlayground requires SMTP auth. The backup script is not hard to enhance to support SMTP auth. It can be done as follows:

In the configuration section of the file (around line 203), add 2 new variables:

$smtp_user           = "my username"
$smtp_password       = "my password"

Around line 1200, add in the AuthUser and AuthPass:

MIME::Lite->send("$send_method", "$mailprog_or_smtp_host", Timeout=>60,
            AuthUser=>$smtp_user, AuthPass=>$smtp_password);

As an aside, this script can also do backups via FTP.

Restore of mysql dump files is pretty easy. You just use the standard client:

mysql -uMyUser -p MyDatabaseName < SqlDumpFile.sql

Some Murakami Quotes

Recently, I’ve been catching up on my reading. Haruki Murakami is one of my all time favourite authors. His novels are always interesting, and the writing style is generally gorgeous, although it does vary a little between different books. I’m not sure if this is Haruki Murakami changing his style in the original Japanese, or simply results from different translators.

Something I’ve been noticing lately is that in all of the Murakami novels I can recall, the protagonist always has a lot of time. This is so different to most other novels which try to rush from one exciting event to the next. Perhaps this is part of the reason why I really like Murakami’s writing so much. Anyway, here’s some memorable quotes from Murakami novels that I’ve read recently:

From Kafka on the Shore:
“Perhaps most people in the world aren’t trying to be free, Kafka. They just think they are. It’s all an illusion. If they really were set free, most people would be in a real pickle. You’d better remember that. People actually prefer not being free.”

“Pointless thinking is worse than no thinking at all”.

From Hard-Boiled Wonderland and the End of the World:
“Huge organisations and me don’t get along. They’re too inflexible, waste too much time, have too many stupid people.”

“It’s frightening,” she said. “Most of my salary disappears into my stomach.”

From The Wind Up Bird Chronicles: (language warning on this one)
Show quote, although it contains 4-letter words.

Opera Browser – Lean and quick

I’ve been using Firefox since its inception, and its glorious introduction of tabbed browsing. However, every new update, Firefox seems to get ever slower, and use more memory and more processor.

Finally, last week, after Firefox hung yet again using 100% of processor and over 300mb of memory, I decided to give Opera a go. So far, I’ve been very satisfied. It was a small download, easy install and uses about 1/3 of the memory and significantly less processor than Firefox does, especially when you have many tabs open and leave the same instance of the browser running for several days. I’ve had one crash when setting up Adobe Acrobat preferences, but in general browsing, it is yet to break. Pages load faster, and rendering of HTML and CSS seems fine. The only problem I’ve had is with Lotus Notes Webmail saying Opera is “not supported” and not wanting to run.

So far, I’ve installed Opera on older Windows and Mac boxes, and been very happy with the improved browsing experience. I still keep my Firefox handy though, mainly for its great web development plug-ins (Firebug and friends).

Hosting at Rails Playground, a review

I’ve been meaning to write about Rails Playground for a while. I currently use their level 2 developer hosting and I’ve been very happy with it. I host several domains and subdomains on my account. I run several rails apps (including my online wedding registry site, this blog (WordPress) and a wiki (moin) on it.

You get shell access, sFTP and cPanel, MySQL, PostgreSQL and also unlimited subversion repositories. Another neat feature is that you get 2 mongrel instances included. You need to ask Rails Playground staff to set these up for you, but they are quite prompt and friendly. I did have some problems with Mongrel instances dying, but the Rails Playground staff added a cron job to restart them, and this has solved the issue. At currently $12/month (or $9/month if you pay for a year), it is quite economical hosting.

I’d highly recommend Rails Playground if you’re a rails developer looking for hosting (with fcgi and mongrels) and subversion, and you don’t want/need the flexibility/hassle/higher price of a virtual private server.

Wedding Registries for the Pommies

Update: I closed down this site in 2013, and let the domain lapse. In 2023, a zombie version was set up by parties unknown at the same domain, using my pages scraped from the wayback machine. This site does not work, and is not run by me despite having my name on it. I am attempting to have it closed down.

Your Wedding Presents now shows all money amounts in pounds, if you say you are from the United Kingdom. God Save the Queen!

Delicious .NET – Slides & Code

Here’s the slides and code from yesterday’s “Delicious Dot Net” talk at ACS.

ACS Talk – “Delicious .NET” – 3rd Oct

I’ll be giving a talk at an ACS event after work on Wed next week (3rd October). Here’s the blurb:

A tasty take on WPF, WCF, LINQ and O-R Mapping

An exploration of some of the freshest, tastiest and most powerful features in .NET 3.5 through implementing a useful application.
You’ll take away an understanding of what’s in .NET 3.5 and how to build online and offline applications with the new technology stack supported by Visual Studio 2008 (Orcas Beta 2).

Location
Norman Selfe Room,
Level 3,
280 Pitt St Sydney (Sydney Mechanics School of Arts)

Time
6:15pm, 3rd October 2007

For more info or to register, please visit the ACS site.

Hope you can come 🙂

Reflexil, cute code injection for C#

While catching up on my favourite blogs, I came across Reflexil on Fabrice’s blog. Reflexil is able to do C# code injection into existing assemblies and save the resulting assembly. I haven’t given it a go yet, but it looks like a really neat tool. The legal implications may mean it is only useful for emergency patching or debugging however…

WebJam this Saturday Night

WebJam is usually quite fun. The premise is that a large group of people meet in a pub, have a few drinks (often sponsored by some generous company) and see quite a number of presenters who have 3 minutes each to show off cool, web-related stuff they’ve done recently. The next one is this Saturday. Details as follows:

Place: Bar Broadway (opposite UTS)
Date: 29 Sept 07
Time: 6pm

I’m planning to go, and also to give a 3 minute presentation on my new free wedding registry site.

Hope to see you there!

JRuby on Rails with GoldSpike – Scaling for more users

The default configuration for running JRuby on Rails using GoldSpike only allows 4 instances of the JRuby runtime. This means that if there are more than 4 simultaneous requests from clients, the web server will respond with a server overloaded error. The easiest way to see what’s going on is to take a look at the ‘createObjectPool’ method of RailsServlet.

With a dedicated production server with 1gig of memory, it is possible to allow a lot more JRuby runtimes, and hence allow for more simultaneous users. A little load testing on a fairly small app suggested that 20 instances of JRuby runtime would fit comfortably under the 1gig ceiling and not overload the processor.

An easy way to change the max number of runtimes is to edit ‘web.xml’ in a JRuby application’s WEB-INF directory. Parameter is set as follows:

  <context-param>
    <param-name>jruby.pool.maxActive</param-name>
    <param-value>20</param-value>
  </context-param>

It is also worth checking with the web server configuration to ensure that the web server allows more threads than the number of JRuby runtimes specified in ‘web.xml’.

Page 13 of 20

Powered by WordPress & Theme by Anders Norén