Archive for May 2008

 
 

Automated Backups with Windows and Ubuntu, Part 1

To me, one of the most important things is keeping consistent backups of all of my data. Years ago, it was easy enough to keep data backed up on a couple of floppy disks. After that, data began spanning a couple of Iomega Zip disks. Once CD burners became popular, I ended up burning my files to a couple of CD’s each month. In the past few years, it’s become necessary to keep information stored on a separate hard drive just in case another one fails.

For a few months, I was using DriveImage XML to keep weekly snapshots of my important data. It worked fine; however, I began to notice that the level of file fragmentation on my hard drive following a snapshot was ridiculously high. Over the past couple of weeks, I’ve been investigating a couple of different reliable backup solutions. The most important thing to me is to be able to keep frequent - as in weekly - snapshots of my data, have it stored in a location that is easily accessible, and have a low risk of having the storage medium fail.

At first, I heavily considered using Amazon S3 . It would allow me to store my data in the cloud in a very secure, very reliable medium. I’m still considering using it at some point, but I’ve opted for a slightly simpler solution. Although it’s not quite as attractive as S3, it’s cheaper and, for now, that was the ultimate selling point. Before going into the details of how I automate my backups, it’s worth noting my setup.

My System Setup

I’ve got two computers - one running Windows XP and another running Ubuntu Linux. The XP machine contains two hard drives. One drive contains the operating system and all of the program files, and the other drive contains all of the data that I deem worth backing up. My Linux box acts as a local web server and local file server. It currently serves as a place on which to test various web development projects, and also a place to host other various files.

The primary reason that my files reside on my Windows machine is because I use that box for most of my projects. Considering the majority of the stuff that I do is oriented in web development, and, as much as I love Linux, the majority of people that use the web are still using Internet Explorer, Windows is a larger target for web development. This can be debated, but that’s another post so I digress. Anyway, to that end, I need to have fast access to some of my files while working on things.

How I Backup My Data

Introducing SyncToy

Since Windows 95, Microsoft has released free, small utilities for its operating system known as PowerToys . While investigating alternative backup solutions, I came across one called SyncToy . It’s an extremely easy-to-use, utterly simplistic PowerToy. At first, I was really skeptical as to if something this simple would serve as a solid backup solution. Because it would take next to no time to download and install it, I gave it a try. Surprisingly enough, I’ve been really pleased. In fact, I’ve ended up using SyncToy to automate my backups for the past couple of weeks.

The thing about SyncToy is that it serves one purpose and fully recognizes what it is. It doesn’t try to do more than it should, or attempt to present itself as the end-all-be-all of backup software. I like it because it knows its place, so to speak. With that said, SyncToy offers several options for backing up your data. These options include…

  • Synchronization. This option will take the newest files from either drive and copy them to the drive that has an older or non-existent version. It will also make sure that each drive as the most updated filenames, and no drive has files that the other does not. This option is useful if you frequently save data to more than one drive.
  • Echo. This option will take all files from a source drive and copy them to the destination drive. If a file has been renamed or deleted on the source drive, this change will be reflected on the destination drive.
  • Subscribe. This option will take files that have been updated on the “right drive” (typically the destination drive) and copy them over to the “left drive” (typically the source drive).
  • Contribute. Contribute is similar to subscribe; however, the drive from which operations are performed is reversed. Files that are new and/or updated on the “left drive” (again, typically the source drive) are copied to the “right drive” (which is usually the destination drive). No files are deleted in Contribute mode.
  • Combine. This operation will combine new and updated files from either drive much like synchronization mode; however, no renamed files or deleted files will be handles.

For my purposes, Echo works the best. I keep all of my data on an internal drive and want that data replicated to two locations - more on this in a bit.

Automating Backups with SyncToy

Of course, backups should be automated - no one wants to initiate a backup of their data while they are at their computer because it’s inconvenient. Operations like this not only take time, but it’s usually lame to be working on a system while it’s busy performing a bunch of file operations. Luckily, SyncToy can be run via the command-line and, thus, can be setup as a scheduled task in Windows to run automatically.

For those of you that are interested, setting up SyncToy to perform automatic backups it easy. Assuming that you’ve already setup your folder pairs (or your source drive and destination drive within SyncToy). here’s how to schedule an automatic backup…

  1. Launch the Scheduled Tasks applet from the Start | Programs | Accessories | System Tools menu and double-click on the Add Scheduled Task icon. This will launch the Scheduled Task Wizard.
  2. When you’re asked to select the application for Windows to run, click Browse.. and find the SyncToy executable on your hard drive. Mine is located in C:\Program Files\SyncToy\SyncToy.exe .
  3. On the next screen, select how often you want the task to run. I have mine set to Weekly .
  4. Next, you’ll be asked to pick details about the task. Select a time, how many weeks, and the day(s) during which you want your backups to occur.
  5. Enter in your Windows username and password to complete the scheduled task.
  6. On the final screen, check the option that reads Open advanced properties for this task when I click Finish and then click Finish .
  7. In the Run field of the advanced properties, you’ll need to make a modification. Make sure that it contains this (including the quotation marks): “C:\Program Files\SyncToy\SyncToy.exe” -R . The -R parameter instructs SyncToy to backup all folder pairs as you’ve configured them.
  8. Click OK and confirm your Windows username and password.
  9. Click Apply and then OK . You’re done.

Based on the scheduled settings that you’ve specified and assuming that you leave your machine running all of the time, SyncToy will now regularly backup your data based on the folder pairs that you’ve configured within the application.

Backing up in multiple locations?

As previously mentioned, I actually have SyncToy backing up to two locations - since I’m not going to have the security of data redundancy that a larger service can provide, I decided it best to perform a scheduled backup to two separate locations rather than just a single drive. Call me paranoid of losing my data.

One of the automated backups goes to an external hard drive that I have connected to my machine. This allows me to keep one copy of my files that I can take with me if I ever need to do so. The other backup is sent to my Linux file server via a network drive. This network drive matched with SyncToy’s automated backups provides a really easy way to keep your files on a secondary Linux machine while simultaneously having access to some of those files should you ever need them on your local Linux installation.

In a follow-up post, I’ll explain how to map a network drive from a location on your Linux file server to your Windows machine and schedule your backups to that location. Of course, I’m always on the look out for other ways to reliably, securely, and inexpensively backup my data. If you’ve got one or have any suggestions for using SyncToy, feel free to recommend them.

Slideshow JS 1.5 Released

I just released the most recent version of Slideshow JS. Version 1.5 brings with it major code changes that improve overall performance. I received several emails asking for various features and I incorporated many of them. Additionally, I addressed all of the known CSS bugs that were found. Here’s a short overview of the new features that have been introduced…

Improved management of variable sized images
If your slideshow contains images of variable widths, all images will be centered in the slideshow container.

Manual control
You can now manually cycle the slideshow by clicking on the current image.

Image display limit
Slideshow JS can display however many images you specify and then stop.

Configurable transition speed
You can now update how fast the fading transition lasts while cycling images.

Pause control
If specified, the current slideshow can be paused by hovering your mouse over the currently active image.

Image titles
Slideshow JS will not display a title bar containing a title for each image as specified by you.

Custom stylesheets
The pause message and title bar are completely customizable via your own stylesheets.

To see more of the script and for more detailed information, visit the project’s website. As usual, send me an email or leave a comment regarding your thoughts on the script.

Improving ProFTPD speed in Linux

If you’re currently running an FTP server with ProFTPD on your Linux machine, then you’re probably not experiencing the best transfer performance. To improve the speed of transfer from within your LAN (and even the outside world), two lines need to be added to the ProFTPD configuration file.

Assuming that you’ve got an XAMPP setup (if not, just find the proftpd.conf file on your file system), do this:

$ sudo gedit /opt/lampp/etc/proftpd.conf

and add these two lines at the bottom of the file. You may want to add a comment to remind yourself why you added these lines.

# Improve rate of transfers
IdentLookups Off
UseReverseDNSLookup Off

Restart the daemon and you should be good to go.

Addressing Prototype, setStyle, Internet Explorer, “Object doesn’t support …”

While working on the latest version of Slideshow, I was working on a feature that involved dynamically creating an element, creating a text node, and ultimately setting styles on the new element. Unfortunately, IE6 and IE7 kept throwing the error “Object doesn’t support this property or method”. When searching for the bug, I had narrowed it down to the function responsible for setting the styles of this newly generated element. Initially, my code looked something like this:

this.Message = document.createElement(’div’);
var msg = document.createTextNode(’[message goes here]‘);
this.Message.appendChild(msg);
this.Message.setStyle({

// styles

});

I traced the problem to the line where the styles were being set (this.Message.setStyle). The fix is pretty simple - rather than saying:

this.Message = document.createElement(’div’);

I needed to do this instead:

this.Message = $(document.createElement(’div’));

From what I can tell (and I could be way off), IE manages the DOM a bit differently than Opera, Safari, and Firefox and, although Prototype seeks to grab the element using the $() function in the code, you must explicitly use $() when creating your node.

PHP & IIS: Addressing “Fatal error: Call to undefined function mysql_connect()”

I’ve been working on a project that is hosted in a Windows environment, but requires PHP and MySQL. My development and test environments are using the LAMP stack with which I’ve never had any trouble getting the two modules to play nicely. Going into the project, I knew that it was a little more of a headache to setup PHP and MySQL with an IIS webserver, but I also knew it could be done. I installed PHP and MySQL and also made the appropriate changes to the PHP.ini file. Unfortunately, PHP was still not able to interface with the database and I received this error:

Fatal error: Call to undefined function mysql_connect()

If you’ve suffered from this problem, here are a couple of things to check in a roughly appropriate order.

  • Make sure that you have the correct parameters in your PHP code. Often times in development, you’ll be connecting to a development database or a test database and forget to modify the script when you push to production.
  • Verify that php_mysql.dll is located in your PHP installation directory and that you uncomment the line in PHP.ini that contains extension=php_mysql.dll.
  • Lastly, make sure that you’ve setup your Environmental Variables in Windows. To do this, Start | Settings | Control Panel | System. Click on the ‘Advanced’ tab, then click the ‘Environmental Variables’ button. In the ‘System Variables’ frame, click on ‘New’ and then give the variable name ‘PHPRC’ and give the value to the root directory of your PHP installation (such as C:\PHP). Restart the machine (not just the webserver).

I failed to perform Step 3 in my initial configuration; however, after I restarted the server everything worked exactly as it should. If you’ve experienced this error, and none of the above help to address the problem, leave me comment - I’m interested to see any other erratic behavior that may occur in an IIS/PHP/MySQL environment.

Edit: May 22, 2008
Matt left a comment about a MySQL function freezing his machine that was running IIS6. Despite a few initial thoughts, I really wasn’t sure what had happened. After a short email exchange, he let me know what the problem was and how to fix it, so I’m including his response as another tip for this post:

  • “It turns out that the IIS installer (.msi version) doesn’t put the proper PHP path in the mime type. It comes out reading like c:\php\PHP5~.dll which fails to run. I had to change it to the proper path c:\php\php5isapi.dll without the Windows truncation.

    As for the corruption, I have no idea what happened. I had to re-install PHP5 and configure php.ini all over again to get my sites back up.”

Disabling Tab with JavaScript

Occasionally when building web applications, the need arises to stop event propagation and/or event bubbling (for more information, check out this page).

I’ve been working on a control that sits above all of the other elements of the page and must maintain focus of the mouse and keyboard while it is being displayed. In order to do this, I needed to prevent the default behavior of the Tab key whenever this control was visible on the screen. Without going into too many details, I’ll just add that I’m needing to override this behavior in order to make sure the user interacts with the control and cannot bypass it - ultimately, it’s a security measure and it’s for their own good.

Before continuing, I’d like to add that I’m not really a fan of overriding behavior like this. From a usability standpoint, it contradicts what the user thinks will happen when they perform an action versus what will happen. As such, it breaks their conceptual model of how they believe the thing work. Knowing that I’m doing all of this makes me feel lame. Regardless, it’s for their own good. The ends justify the means.

With that said, the major browsers name their event object differently, so you need to get a reference to that object before capturing the event. Next, we only want to stop the default behavior based on the Tab key (which has the keycode of 9). Here’s how to do it such that it works in IE, Safari, and Firefox:

document.onkeydown = DisableTab;
function DisableTab(evt) {

var evt = (evt) ? evt : ((event) ? event : null);
if(evt.keycode == 9) {

return false;

}

}

Again, this is one of those solutions that I’m not really a fan of, but is needed. Many of the alternatives that I found when looking around didn’t work correctly across the major browsers so I ended up doing it this way and it worked.

Slideshow JS 1.5 on its way!

For those of you that are interested, I’ve begun development on Version 1.5 of Slideshow. For more information about the script and some of the upcoming details, check out the Slideshow JS project page.

Overall, I’ve received some really positive feedback and am doing the best I can to incorporate all of the features that have been requested. I’m also going to be addressing a couple of lingering bugs that have been discovered. Once I get closer to releasing the next version, I’ll be sure to outline all of the squashed bugs and feature requests.

If you’d like to be notified whenever the next version is released, sign up using the link on the project homepage or leave a comment on this post.

Site Overhaul - Moving from Chyrp to WordPress

I’ve spent part of this weekend overhauling my site. This was driven by the need for greater organization of content, and better support for visitors. Here’s a quick rundown of what I’ve done to improve the site…

Moved from Chyrp to WordPress

Importing all of my previous content into WordPress from Chyrp was a little more tedious than I was hoping, but it wasn’t terrible. If you’re planning to move from Chyrp to WordPress, here are my recommendations (because I know there are those of you out there that have done it):

  • Backup your database and files first.
  • Export your current RSS feed to a file on your local machine. To do this, simply load up the site in Firefox and choose “File>Save Page As…” and select “Web Page, XHTML Only.”
  • Install WordPress.
  • From the WordPress dashboard, select ‘Manage’, ‘Import’, and select ‘RSS.’ Use the file that you saved in Step 2.

If everything goes correctly, WordPress should list all of the posts that you’ve just imported and generate a success message. Before you’re done with this step, you may want to browse the site and examine your posts - importing from XML can sometimes result in some odd behavior (as a result of how WordPress’ editor and browsers parse CDATA tags differently). Your content is all there, you just may have to clean up some of the residual tags. You can do this by editing a given post in HTML mode.

Built a customized theme

At this point, I’m more concerned with publishing content than building a custom theme, so I met myself in the middle: I found a theme called Simplicity that I really liked, but it still lacked a few things that I wanted. I spent some time tweaking various aspects of the theme and organizing it in such a way that it was conducive to how I’m wanting to organize all of my information.

Because of the amount of modification that I made to the Simplicity theme, I ended up saving it as its own theme. It’s currently not publicly available, but if you’re interested in using it, leave me a comment.

Updated FeedBurner

Chyrp and WordPress each publish separate feeds. Luckily, I had been using FeedBurner prior to migrating to WordPress, so I was able to update the feed from withing the FeedBurner dashboard. This should take care of current subscribers all the while allowing me to maintain stats with no real loss of data.

Unfortunately, this may result in a few readers displaying information differently. For instance, Google Reader displays the RSS 2.0 feed differently than Firefox’s Live Bookmarks. Additionally, some readers may show a lot of my previous posts as new posts.

Installed the latest version of Google Analytics

During my time of using Google Analytics, they released a new version that I never actually used on my old platform. This is nothing more than sheer laziness, but it’s given me the change to incorporate the new version into this site.
Overall, this migration was a relatively painless process. Hopefully content publishing will be much easier, comments will be managed more efficiently, and overall visitor experience will be better.

WordPress 2.5, RSS, and Ampersand Encoding

Recently, WordPress 2.5 was released and its corresponding minor bug-fix release, version 2.5.1, was released as well. This was a relatively solid upgrade. The overhaul of the interface was a welcome change; however, the upgrade ended up causing some major problems with its RSS syndication.

First off, there was some under-the-hood changes that changed how users access RSS feeds based on how the permalinks are configured. For example, if you’re using permalinks in the format of /year/date/day/title, then you should use the RSS format of /feed/rss.

Secondly, the upgrade actually broke RSS2 feeds. You can read an entire forum post about it here on the WordPress forum. This was quickly addressed and the bug fix is available in this changeset. In my opinion, these are the types of bugs that should’ve been found during testing of such a major release - I don’t get why something like this wasn’t caught.

Lastly, I was burned twice on the RSS issue. Once I patched my installation with the bug fix that I just mentioned, I noticed that my RSS2, ATOM, and RDF feeds still weren’t working. I ended up tracking it down to a problem with failing to encode an ampersand. Specifically, the author’s ‘friendly name’ included an ampersand and it was written into the database without being encoded - parsers do not like the ampersand if it isn’t encoded as it’s usually used as a delimiter for key/value pairs. Because of this, the XML used in publishing the feed was invalid.

Once I made this modification in the database, all of the feeds went live again. Just like the WordPress developers should have caught their RSS issue before releasing, I should have caught that issue when configuring the site.

Dropbox Finally Live

Yesterday, I got my invitation to try out Dropbox. As of now, there are clients available for Windows and Mac. According to the forums, the team is working on a client for Linux. You’re given 2gb of storage, and several invitations to pass out to friends.

I’ve got a few invitations remaining, so let me know if you’d like one. In the coming week or so, I’ll try to post my thoughts on the service.