The blog of dlaa.me

Dynamic content made easy *redux* [How to: Use the new dynamic population support for Toolkit controls]

I previously blogged a sample demonstrating how to use the AJAX Control Toolkit's dynamic population functionality with a data-bound ModalPopup. That sample was well received, but some of the changes that happened as part of the ASP.NET AJAX Beta 1 and Beta 2 releases have rendered the sample code I originally posted un-runnable on current builds.

No worries - it's a simple matter to update the sample and the exercise should serve as a good example of some of the things that need to be done as part of an upgrade. (For a far more in depth guide to upgrading, please refer to Shawn's AJAX Control Toolkit Migration Guide and follow-up about upgrading Web Services/Methods.)

Referring to the sample code I posted earlier as a starting point, the 5 things we need to do to update it are:

  1. Change the tag prefix for ScriptManager from "atlas" to "asp" to point to the new location for ScriptManager
  2. Change the @Register tag to refer to the AjaxControlToolkit by its new name ("AtlasControlToolkit"->"AjaxControlToolkit" twice and "atlasToolkit"->"ajaxToolkit" once)
  3. Change the corresponding tag prefix for ModalPopupExtender from "atlasToolkit" to "ajaxToolkit"
  4. Copy the properties of the ModalPopupProperties element to the ModalPopupExtender element and remove the empty ModalPopupProperties element now that the XxxProperties elements are no longer used
  5. Update the web method definition by making the GetContent method static and adding the [Microsoft.Web.Script.Services.ScriptMethod] attribute

That's it! As you can see, it's mostly simple "find-and-replace" naming changes that can easily be applied to an entire site at once. The XxxProperties change is slightly more involved, but requires very little effort since it's basically just a "cut-and-paste" operation. The web method changes are also a little bit of effort, but the changes themselves are simple and it's easy to find where to make them by searching for the pre-existing "WebMethod" attribute. Nothing here is risky or error-prone and - with the exception of the web method changes - the compiler will report all of them as errors until they're fixed correctly.

For completeness, here's a reminder of what dynamic population looks like in action:

Animated demonstration

And here's the complete sample code after the changes discussed above have been applied. This sample runs fine on the ASP.NET AJAX Beta 2 and the AJAX Control Toolkit 61106 release:

<%@ Page Language="C#" %>
<%
@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
  TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
script runat="server">
  [System.Web.Services.WebMethod]
  [Microsoft.Web.Script.Services.
ScriptMethod]
  
public static string GetContent(string contextKey)
  {
    
// Create a random color
    string color = (new Random()).Next(0xffffff).ToString("x6");
    
// Use the style specified by the page author
    string style = contextKey;
    
// Display the current time
    string time = DateTime.Now.ToLongTimeString();
    
// Compose the content to return
    return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";
  }
</script>

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head id="Head1" runat="server">
  <title>Dynamic ModalPopup Demonstration</title>

  <%-- Style the page so it looks pretty --%>
  
<style type="text/css">
    body { font-family:Verdana;     font-size:10pt; }
    
.background { background-color:Gray; }
    
.popup { width:200px;             padding:10px;        background-color:White;
            
border-style:solid;      border-color:Black;  border-width:2px;
            
vertical-align: middle;  text-align:center; }
  
</style>
</
head>
<
body>
  <form id="form1" runat="server">

    <%-- Atlas pages need a ScriptManager --%>
    
<asp:ScriptManager ID="ScriptManager1" runat="server" />

    <%-- A very simple data source to drive the demonstration --%>
    
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
      <Data>
        <items>
          <item style="font-weight:bold" />
          <item style="font-style:italic" />
          <item style="text-decoration:underline" />
        </items>
      </Data>
    </asp:XmlDataSource>

    <%-- A simple list of all the data items available --%>
    
<asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">

      <HeaderTemplate>
        How would you like your dynamic content styled?
      
</HeaderTemplate>

      <ItemTemplate>
        &bull; <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style") %>' />

        <%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>
        
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server"
            TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"
            BackgroundCssClass="background" DynamicControlID="Panel2"
            DynamicContextKey='<%# Eval("style") %>' DynamicServiceMethod="GetContent" />
      </ItemTemplate>

    </asp:DataList>

    <%-- All ModalPopups share the same popup --%>
    
<asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;">
      <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>
      <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
    </asp:Panel>

  </form>
</
body>
</
html>

Enjoy!

Just what it takes for Beta 2 [AJAX Control Toolkit update!]

On Monday we made available the 61106 release of the AJAX Control Toolkit. We did this in parallel with the release of ASP.NET AJAX v1.0 Beta 2 in order to accommodate some breaking changes introduced in that release. As such, we did not make any functional changes to the Toolkit in the 61106 release, though we did take the opportunity to fix one or two small bugs that we'd found.

Recall that you can sample any of the controls right now (no install required). Then you can browse the project web site, download the latest Toolkit, and start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!

Talked Toolkit [Spoke at the ASP.NET Connections conference]

As I blogged earlier, I presented the AMS302: "Atlas" AJAX Control Toolkit Unleashed: Creating Rich Client-Side Controls and Components session at the Microsoft ASP.NET Connections conference a few hours ago. This was my first ever presentation at a conference and it was a lot of fun! I hope those of you who attended enjoyed the talk and learned more about the Toolkit - it was great to have an opportunity to talk to you in person!

I've attached my slide deck and the demo content to this post so that anyone who's interested can download it and play around on their own machines.

We're always looking for more contributors and additional control ideas, so please let me know if you want to contribute!

[AMS302-AjaxControlToolkit.zip]

ASP.NET AJAX née "Atlas" - and all that entails... [AJAX Control Toolkit update!]

It wasn't as easy as anybody claimed it would be, but my team just published the 61020 release of the AJAX Control Toolkit (formerly the "Atlas" Control Toolkit)!

What's new in this release? Umm, pretty much everything. :)

Kidding aside, we probably touched just about every line of code in the Toolkit during this release. Why? Well, because we sim-shipped (simultaneously shipped) with the new ASP.NET AJAX v1.0 Beta, a pretty fundamental set of changes to the framework formerly code named "Atlas". The many changes are detailed on their web site, so I won't bore you with the details here. Suffice it to say that their changes impacted the Toolkit in a major way since we build directly on top of them. Some of the specifics of the Toolkit migration process itself are detailed on Shawn's blog, so I won't repeat them here, either.

What I *will* do is highlight our new controls for this release:

I'd also like to single out four of our contributors who made significant contributions to the code that's part of this particular release. To be sure, we have other contributors who've been tremendously helpful in numerous ways and who we'd be lost without. However, these four folks made specific contributions to this release that were very much appreciated. My new best friends are:

And thanks to *everyone* who helped get this release out the door!

As usual, the release notes outline a bunch of other changes we've made. Please take a moment to read about the new stuff. While you're at it, sample any of the controls right now (no install required). Then browse the project web site and download the latest Toolkit so you can start creating your own controls and/or contributing to the project!

If you have any feedback, please share it with us on the support forum (or email me)!!

Talkin' Toolkit [Speaking at the ASP.NET Connections conference in November]

I'll be presenting the AMS302: "Atlas" Control Toolkit Unleashed: Creating Rich Client-Side Controls and Components session at the Microsoft ASP.NET Connections conference on November 7th in Las Vegas. The session's description is:

The "Atlas" Control Toolkit is a set of controls and extenders designed to help ASP.NET developers easily integrate rich client UI features into their Web applications. As a community effort, the Toolkit contains controls written by Microsoft and non-Microsoft developers who have joined forces to create a powerful, shared-source library for all to use. You will learn how to integrate Toolkit components into your application as well as get an idea of how easy it is to create "Atlas" extenders using the Toolkit.

If you will be attending the conference (or otherwise in the area) and would like to get together, please let me know and we'll make plans!

Dynamic content made easy [How to: Use the new dynamic population support for Toolkit controls]

One of the more frequent requests we've gotten for the "Atlas" Control Toolkit is some way to easily alter the content of a popup before displaying it to the user. Typically, page authors want to have a single popup element on their page that is used from multiple locations (often the rows of a data-bound server control) and they want the popup to display information specific to each location that displays it. For example, a page displaying multiple products might want a popup associated with each product to display additional details for that particular product.

There was previously no easy way to accomplish this task, but with the 60914 release of the Toolkit, we've made it simple! The HoverMenu, ModalPopup, and PopupControl now all derive from new DynamicPopulate*Base classes (see the "Other neat stuff" page for details) and automatically expose four new properties: DynamicControlID, DynamicContextKey, DynamicServicePath, and DynamicServiceMethod. These properties behave just like they do for the DynamicPopulate control (please follow that link for more details) and the existing controls have been modified to call the "populate" function as part of their popup actions.

What this means for page authors is that it's simple to add dynamic population to new/existing pages - what it means for control authors is that it's simple to add dynamic population to new/existing controls!

Here's what dynamic population looks like in action (I've arbitrarily chosen ModalPopup for the demonstration):

Animated demonstration

The complete code for the sample follows; noteworthy sections have been bolded to make them stand out. The important things to note are:

  • The page content is generated by data binding an XmlDataSource to a DataList. The data are simple CSS style declarations that are used to decorate the dynamic content when it renders. The user can select which decoration to apply by choosing any of the links on the page.
  • Each row of the DataList includes a ModalPopupExtender declaration that pops a modal panel when the CSS style declaration is clicked. All ModalPopupsExtenders share the same popup element in order to avoid unnecessary duplication. The text of the row and the DynamicContextKey of the ModalPopupProperties are both set by a (data bound) call to Eval.
  • The popup (Panel1) contains both static content and dynamic content (Panel2). The static content includes the "OK" button that dismisses the popup. The dynamic content consists of the current server time which is styled according to the selected row's CSS style declaration and displayed in a random color.
  • The dynamic content is generated by a page method which uses its context key parameter to identify the specific row that is being dynamically populated. (Here, the context key is the CSS style declaration, but typically it might be a database index or row number.)

That's all there is to it!

Just save the following code to an .ASPX file in the SampleWebSite directory of a Toolkit installation if you want to try it out for yourself:

<%@ Page Language="C#" %>
<%
@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit"
  TagPrefix="atlasToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
script runat="server">
  [System.Web.Services.WebMethod]
  
public string GetContent(string contextKey)
  {
    
// Create a random color
    string color = (new Random()).Next(0xffffff).ToString("x6");
    
// Use the style specified by the page author
    string style = contextKey;
    
// Display the current time
    string time = DateTime.Now.ToLongTimeString();
    
// Compose the content to return
    return "<span style='color:#" + color + "; " + style + "'>" + time + "</span> ";
  }
</script>

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
  <title>Dynamic ModalPopup Demonstration</title>

  <%-- Style the page so it looks pretty --%>
  
<style type="text/css">
    body { font-family:Verdana;     font-size:10pt; }
    
.background { background-color:Gray; }
    
.popup { width:200px;             padding:10px;        background-color:White;
            
border-style:solid;      border-color:Black;  border-width:2px;
            
vertical-align: middle;  text-align:center; }
  
</style>
</
head>
<
body>
  <form id="form1" runat="server">

    <%-- Atlas pages need a ScriptManager --%>
    
<atlas:ScriptManager ID="ScriptManager1" runat="server" />

    <%-- A very simple data source to drive the demonstration --%>
    
<asp:XmlDataSource ID="XmlDataSource1" runat="server">
      <Data>
        <items>
          <item style="font-weight:bold" />
          <item style="font-style:italic" />
          <item style="text-decoration:underline" />
        </items>
      </Data>
    </asp:XmlDataSource>

    <%-- A simple list of all the data items available --%>
    
<asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource1">

      <HeaderTemplate>
        How would you like your dynamic content styled?
      
</HeaderTemplate>

      <ItemTemplate>
        &bull; <asp:LinkButton ID="LinkButton" runat="server" Text='<%# Eval("style") %>' />

        <%-- The ModalPopupExtender, popping up Panel1 and dynamically populating Panel2 --%>
        
<atlasToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server">
          <atlasToolkit:ModalPopupProperties
            TargetControlID="LinkButton" PopupControlID="Panel1" OkControlID="Button1"
            BackgroundCssClass="background" DynamicControlID="Panel2"
            DynamicContextKey='<%# Eval("style") %>' DynamicServiceMethod="GetContent" />
        </atlasToolkit:ModalPopupExtender>
      </ItemTemplate>

    </asp:DataList>

    <%-- All ModalPopups share the same popup --%>
    
<asp:Panel ID="Panel1" runat="server" CssClass="popup" style="display:none;">
      <p>This popup popped at <asp:Label ID="Panel2" runat="server" /> and all was well.</p>
      <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
    </asp:Panel>

  </form>
</
body>
</
html>

If you found this "How to" helpful or if you have any suggestions for ways in which future "How to"'s could be improved, please let me know. Thank you!!

Nearly breaking news ["Atlas" Control Toolkit updated again!]

My team just [okay, *almost* just :) ] published the 60914 release of the "Atlas" Control Toolkit. Here are the highlights from the release notes:

  • 4 new controls
    • Animation: Adds powerful, easy to use animations to any element or control
    • NoBot: Applies simple rules to prevent automated bots or scripts from posting to a page
    • Slider: Adds an elegant scrollbar-like user interface for setting numeric values
    • UpdatePanelAnimation: Animates page elements corresponding to hidden postback activity
  • Made Microsoft.AtlasControlExtender.dll functionality public and integrated it into AtlasControlToolkit.dll
  • Added animation framework that makes creating and running complex animations easy
  • Added Atlas profile service support to the extender base class to make persisting values easier
  • Added DynamicPopulate*Base classes to make it easy to add DynamicPopulate functionality to any extender
  • Added PageRequestManagerID property to BehaviorBase to allow behaviors to easily hook up to partial update begin/end events

Of particular note are the integration of Microsoft.AtlasControlExtender.dll and the new animation framework:

  • Microsoft.AtlasControlExtender.dll contains the extender framework itself and was formerly available only in binary form. By making that code public under the same permissive license that the rest of the Toolkit has, customers are now able to change anything they want about how the Toolkit works. The ability to debug into the extender framework makes finding problems with extenders even easier - and is a great opportunity to understand how things work behind the scenes!
  • The new animation framework makes extremely powerful and flexible animation capabilities very easy to add to new code or integrate with existing code. In addition to supporting a simple XML-like declarative language for specifying arbitrary animation behaviors (including support for sequential, parallel, and conditional animations), it's possible to invoke simple animations with just one "goof-proof" line of code!

The release notes outline a bunch of other improvements we've made. Please take a moment to read about the new stuff. While you're at it, sample any of the controls right now (no install required). Then browse the project web site and download the latest Toolkit so you can start creating your own controls and/or contributing to the project!

As always, if you have any feedback, please share it with us on the support forum (or email me)!!

An example of watermark-friendly popping [How to: Integrate the PopupControl and TextBoxWatermark]

One of the questions that comes up every now and then on the "Atlas" Control Toolkit support forums is how to point both the PopupControl and the TextBoxWatermark at the same TextBox. The straightforward implementation doesn't work quite right because both controls assume they have complete control over the TextBox. What happens is that the PopupControl's result gets written directly into the TextBox where it partially overwrites the watermark that's already there. But the TextBoxWatermark doesn't realize anything has happened and assumes the TextBox is still empty. Nuts...

The solution to this problem is not immediately obvious, so I thought I'd post a simple example to help show how it's done using the 60731 release of the Toolkit.

First, here's what the sample code below looks like when it's running:

Animated demonstration

The complete code for the sample follows - most of what's there is just to get the necessary elements on the page hooked up properly. There are a few things worth noting, though:

  • The unique "ID" attributes on the PopupControlProperties and TextBoxWatermarkProperties elements prevent the automatically assigned IDs (which are based only on the TargetControlID (that's common to both elements)) from clashing.
  • The CommitProperty on the PopupControlProperties defines a custom expando property of the TargetControlID (TextBox1) into which the result of the popup will be placed. This keeps the PopupControl from blindly stomping on the text/watermark in the TextBox.
  • The CommitScript on the PopupControlProperties points to a script that gets run when the popup returns (after the CommitProperty has been populated). In this case, the script simply gets the popup result from the CommitProperty and uses the TextBoxWatermark behavior's set_Text method to safely set the text into the TextBox without breaking the watermark behavior.

That's all there is to it!

Just save the following code to an .ASPX file in the SampleWebSite directory of a Toolkit installation if you want to try it out for yourself:


<%@ Page Language="C#" %>
<%
@ Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="atlasToolkit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
script runat="server">
    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        
PopupControlExtender.GetCurrent(Page).Commit(RadioButtonList1.SelectedValue);
        RadioButtonList1.ClearSelection();
    }
</script>

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
    <title>PopupControlWithTextBoxWatermark</title>
    <style type="text/css">
        .watermark { background-color:#bbbbff; font-style:italic; }
        
.panel { background-color:#bbffbb; visibility:hidden; }
    
</style>
</
head>
<
body>
    <form id="form1" runat="server" style="background-color: #dddddd; width: 350px; height: 250px;
        border-style: dashed; border-width: 1px; padding: 5px;">

        <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />

        <asp:TextBox ID="TextBox1" runat="server" Width="150"></asp:TextBox>
        <asp:Panel ID="Panel1" runat="server" Width="125px" CssClass="panel">
            <atlas:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:RadioButtonList ID="RadioButtonList1" runat="server"
                        OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true">
                        <asp:ListItem Text="Red" />
                        <asp:ListItem Text="Green" />
                        <asp:ListItem Text="Blue" />
                        <asp:ListItem Text="[Clear]" />
                    </asp:RadioButtonList>
                </ContentTemplate>
            </atlas:UpdatePanel>
        </asp:Panel>

        <atlasToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server">
            <atlasToolkit:TextBoxWatermarkProperties TargetControlID="TextBox1" WatermarkCssClass="watermark"
                WatermarkText="Favorite Color" ID="TextBoxWatermarkBehavior" />
        </atlasToolkit:TextBoxWatermarkExtender>
        <atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">
            <atlasToolkit:PopupControlProperties TargetControlID="TextBox1" PopupControlID="Panel1"
                Position="Bottom" ID="PopupControlBehavior" CommitProperty="favoriteColor"
                CommitScript="commitScript()" />
        </atlasToolkit:PopupControlExtender>

        <script type="text/javascript">
        // Called when PopupControl has been dismissed (registerd via CommitScript property on
        // PopupControlProperties)
        function commitScript() {
            
// Get the comitted property from the specified expando property on the TargetControlID
            // (CommitProperty above)
            var favoriteColor = $("TextBox1").favoriteColor;
            
// If it's the magic value "[Clear]", then set empty text into the textbox (which
            // restores the watermark)
            if("[Clear]" == favoriteColor) {
                favoriteColor =
"";
            }
            
// Call into the TextBoxWatermark behavior to set the desired text
            $object("TextBoxWatermarkBehavior_TextBox1").set_Text(favoriteColor);
        }
        
</script>

    </form>
</
body>
</
html>

If you found this simple "How to" helpful or if you have any suggestions for ways in which future "How to"s could be improved, please let me know. Thank you!!

A late announcement and an even later announcement ["Atlas" Control Toolkit updated (twice)!]

I'm happy to announce the 60731 release of the "Atlas" Control Toolkit (which came out two weeks ago)! (I'm also happy to announce the 60626 release of the "Atlas" Control Toolkit which came out about a month and a half ago - but that's old news by now and is only included here for completeness.)

Why the delays?

Well, there was a good reason for keeping the 60626 release a little quiet. The "Atlas" team released an updated version of their binaries just a few days after our 60626 release came out - so the bits it included were suddenly out of date. We expected to integrate the new "Atlas" bits and put out an updated release of the Toolkit a day or two later, but various issues came up and we weren't able to do so. By the time we'd resolved all of the issues, it was just about time for the 60731 release!

So that's why there was no announcement for 60626. But why the delay for the 60731 release?

No good reason, really, other than that I've been busy with other stuff and haven't posted to my blog in a while... :|

 

Without further ado (or excuses), here are the highlights of the new releases:

  • 8 new controls
    • Accordion: Displays one pane at a time from a set of multiple panes
    • DynamicPopulate: (Re-)populates any element with HTML content downloaded from the server
    • FilteredTextBox: Prevents unwanted characters from being typed into a text box
    • NumericUpDown: Lets you attach flexible up/down "spinners" to any TextBox
    • PagingBulletedList: Adds flexible paging and sorting to any bulleted list
    • PasswordStrength: Provides interactive feedback about the strength of a password being created
    • Rating: Displays a "4 out of 5 stars" interface for ranking
    • ResizableControl: Makes any control resizable
  • A complete automated testing framework along with tests for all 21 controls in the Toolkit
  • Data binding support for extender properties declarations
  • Support for the July CTP of "Atlas"
  • An established process that allows anyone to contribute to the project (5 of the controls above were by people who aren't on the Toolkit team!)

The release notes outline a bunch of other improvements we've made. Please take a moment to read about the new stuff. While you're at it, sample any of the controls right now (no install required). Then browse the project web site and download the latest Toolkit so you can start creating your own controls and/or contributing to the project!

As always, if you have any feedback, please share it with us on the support forum (or email me)!!

A brief bit 'bout backups [My current backup strategy]

I've seen a few references to backup strategies on blogs and discussion lists lately and thought I'd write a bit about the strategy I recently decided on and implemented. Of course, everyone has their own approach to file management, their own comfort level for security, and their own ideas about what's "best". That's life and I'm not going to try to persuade anyone that my way is better than their way - but I will outline my way in case it's useful for others, too. :)

The setup: My machine is running Windows 2003 Server and I try to keep as much unnecessary stuff off it as possible (no games, no P2P programs, no weird drivers, etc.). Along the same lines, all user accounts on the server are members of the restricted access Users group, not the Administrators group. The machine has one hard drive for storing the operating system and all programs (60 GB) and another hard drive for storing all data (320 GB). The data drive has a Mirror directory under which all data to be backed up is stored. The Mirror directory is ACLed to allow the Users group read/write access. Non-private subdirectories of it are shared out for read-only access by Users. I have an external USB 2.0 drive enclosure for backing up to (200 GB) that is normally powered off and that I mirror the Mirror directory to every couple of days or so. The external drive is ACLed to allow only members of the Backup Operators group to make changes. My data consists of the usual personal stuff (email, source code, etc.), all digital photos I've ever taken, all digital video I've ever taken, sentimental stuff (like wedding videos, baby's ultrasound video, etc.), and some of my music collection in WMA Lossless format. Very little data changes day-to-day, so a simple tool like RoboCopy (free with the Windows 2003 Resource Kit) is more than enough to keep the backup directory in sync (use RoboCopy's /MIR switch to make this easy). Along with the rest of the data is a file that records the MD5 hash of every file in the backup. As my data storage needs increase (which they do each time I take a picture or shoot a video!), I'll eventually buy a new large hard drive and swap it for the smallest of the two data drives currently in use. As long as my storage needs don't grow too rapidly, I'm figuring the cost of upgrading to be about $100 each year (that's the cost of a mid-sized drive like the 320 GB I purchased a few months ago). I'm counting on storage capacity to continue increasing like it has so that I'll always be able to buy $100 drives when I need to increase the storage space.

Benefits provided by this approach:

  • All the data I care about is stored in two independent locations, so there's no single point of failure. (Duh, that's why it's a backup.)
  • Hard drive media doesn't suffer from the same "bit rot" problems that can render writable CDs/DVDs unreadable after just a couple of years.
  • The backup drive is completely separate from the primary drive, so if I ever make a mistake and delete something important, I can easily recover it from the backup. (Some RAID-based solutions immediately mirror all changes and therefore don't have this benefit.) Similarly, a destructive virus on my main machine can't immediately destroy all copies of any data.
  • I look over the list of changes whenever I perform the mirroring to the external drive, so I have an additional opportunity to catch accidental deletions, mysterious changes, etc..
  • I have immediate access to all of my data from any machine in my home. If I decide to look at old photos, I can access them just as easily as the photos I took yesterday.
  • All family members store their data under the Mirror directory (via appropriately ACLed shares), so everybody's data is automatically backed up.
  • In the event of a slow-moving catastrophe (ex: a flood) I can easily grab the external backup drive and take it with me wherever I go. All data will be accessible from any other Windows computer in the world.
  • The overall cost was minimal to set up (~$100) and should be minimal to maintain (~$100/year).
  • Data is separate from applications, so I can reinstall or upgrade the operating system whenever I want without worrying about the data itself.
  • User accounts have limited privileges and are therefore less likely to accidentally compromise the machine when reading email or surfing the web.
  • The MD5 hashes mean that it's easy to verify the contents of my backup drive and that I'll be able to detect data corruption problems if they ever happen.
  • The backup drive is ACLed so that I can't accidentally delete data on it.

Problems this approach does not solve:

  • Both drives are at the same physical location, so all data can be lost in the event of a sudden catastrophe (ex: fire, earthquake). Possible mitigation: Set up a third external drive (after the first upgrade) and keep that drive somewhere far away. It may not be big enough to hold everything, but I'm happy to exclude music from the off site backup. Drawback: Inconvenience of updating the off site drive.
  • "Old data" is lost quickly. For example: if I accidentally delete an important file, I need to detect that mistake at the time of the next mirroring or else that file is gone for good. Possible mitigation: Multiple backup drives at staged intervals (ex: 1 week, 1 month, 3 months). Drawback: Cost.
  • A thief who steals the computer or external drive might have access to personal data. Possible mitigation: Encryption. Drawback: Inconvenience of decrypting files to use them and/or backing up EFS keys.
  • This solution may not scale well if my data storage needs increase faster than storage technology does. Possible mitigation: Move to a different backup strategy. Drawback: That strategy will have its own problems.

I think this overview touches on pretty much all of the key points of this strategy. It's obviously not a perfect solution, but it meets most of my requirements and I'm pretty happy with how it's been working out so far. However, I'm always open to improvements - if you have any suggestions, I'd love to hear them!

Tags: Technical