« April 2004 | Main | June 2004 »

May 11, 2004

Backups

Scott asked what others do for backups.

My current strategy isn't perfect by any means, but reliable enough for me now. I'm not overly paranoid about these things -- if I lose something, I'll accept it and move on. Accidents happen -- with physical photos, CDs, DVDs, VCR tapes, etc. Without easy ways of transferring one media format to another, we'll always have this problem; I'm thankful that "digital bits" are easier to move around as it makes my job of preserving memories easier (although with digital rights management, DRM, I'm often thwarted by the legalities of preserving some of the "bits" I have purchased).

Music

We have a large number of CDs that we have stored as Windows Media Format on a centralized server (around 35 GB at 160Kbps). As new CDs are acquired, copies of the new files are stored on two additional IEEE1394-Firewire/USB 2.0 drives which are located offsite (conveniently, in my and my wife's offices, connected to our workstations so that we can access our music at work without bringing in hundreds of CDs). About once a year, I make a complete archival backup of all of the files to a series of DVD-Rs. This is probably not necessary given the redundant copies we have, but it brings a small amount of 'peace of mind' knowing that I won't need to insert hundreds of CDs into my PC waiting minutes for each to copy for a LONG time (until some significantly improved audio format comes along).

Images/Photos

Very similar strategy to music, with the additional step that I also frequently copy the directory structure to my laptop. I may need to change this as the collection is growing significantly, but for now it works. I make CD-R backups of the images every couple of months and take the CD-Rs offsite. Soon I'm going to add an external drive to the main storage drive and mirror it daily (robocopy). Once the collection grows beyond what I want on my laptop, I'll switch to copying only the recent images to my laptop (which is generally what I want to look at anyway), and archiving the remainder in the same way.

Video

This is the one I've struggled with the most. Here's what I do. For new important video (from a camcorder, from the ReplayTV, or whatever), regardless of the size, I find at least one external drive where I can mirror the content while I'm working with the video (making DVDs, etc.). Once the editing has completed, I burn DVDs as necessary. Depending on the size of the files, I may also burn a "source" DVD containing the original files. If the files are too large, I'll batch encode the files to a more compressed format (I usually pick a high quality Windows Media Video Format) and burn these to DVD-Rs. This reduces the file sizes significantly.

I remove the originals from their primary storage location, but keep them on the mirrored external drive. If I run out of space on the mirrored drive (which definitely happens), I am then forced to choose between the content and available space. In almost all cases, I'll delete the older originals, and keep the high quality compressed video files (on DVD). If I really need to make a new video from the files, the archived version should suffice (admittedly at a slightly lower quality, yet still very good). Depending on the importance of the video, I may make extra backups of the DVDs in both final rendered format and the compressed versions.

I have occasionally kept the original source material on "tape", but infrequently. The raw footage is sometimes too raw to bother keeping. I have copied back the edited footage to the tape and saved that. But again, rare.

Personal Files/Documents

Backed up frequently to secondary disc in primary computer, with a copy also made to network storage. Monthly, I make a CD-R of the directory which is generally taken offsite (to work). With the new Winzip 9.0 encryption features, I've considered encrypting the content as well (with the slight worry that I may not be able to access the content due to key management problems on my part). (My wife makes a copy of the Microsoft Money data file to a floppy disk after every update still.)..

Given what I've been reading recently about the potentially limited lifespan of CDs and DVDs, I may need to make duplicates of the back-up CDs and DVDs every couple of years. As new media types (such as the blue-ray DVD drive/disc) become available, I'll transfer the content once it becomes "mainstream" and reasonable priced. The prices of extremely large tape drives are too high for my budget and with my "bits" all around the network on various computers and drives, developing a back-up strategy would be a frustrating experience for me.

Warning

The most important advice I can give though, given my experience: make sure that what you want to backup is in fact being backed up! It's easy to become complacent that your script/utility/etc. is doing the right thing -- computers don't ever make mistakes or have problems, right? Wrong: in the last 6 months I lost of ton of older development projects because of a hard-drive reformat. I thought I had them all backed up in several spots ... turned out my script had a problem and the directory wasn't being copied correctly. Verify that your backups are working.

Summary

  • Make copies of your data as frequently as is important to you.
  • Take some offsite to help in disaster recovery (fire, flood, theft, pet, etc.).
  • Use your favorite calendar software to setup reminders to do any manual backup processes you may have (and don't keep clicking the "remind me in 1 week button").

May 5, 2004

Finding the Component Container

Ever wonder how to create a Component (a non-visual entity) which can automatically obtain a reference to the containing control when it is created? The ErrorProvider component does this. As soon as it is placed on a Windows Form (or more accurately the component tray), the ContainerControl property is set to the Form.

Although it's not hard for developers to manually select the containing control from the dropdown that would be provided, its simple to provide it automatically. Once you see how easy it is to add this support, you'll never go back to the days of manually setting the property again (or forgetting to set it!).

I'll walk you through the basics of creating the component. All of the source you need to make this work is here (in C#).

First, you'll need a component:

public class Demonstration : System.ComponentModel.Component
{ ...

Next, for convenience and to save some keystrokes, you'll want to add a couple of namespaces to your class file:

using System.ComponentModel.Design;
using System.Windows.Forms;

Add a private field which stores the ContainerControl reference:

private ContainerControl _containerControl = null;

Add a property so that users of the component can review or change the value:

public ContainerControl ContainerControl
{
  get { return _containerControl; }
  set { _containerControl = value; }
}

Finally, add an overridden implementation of the Site property:

public override ISite Site
{
  get { return base.Site; }
  set
  {
    base.Site = value;
    if (value == null)
    {
      return;
    }

IDesignerHost host = value.GetService(
typeof(IDesignerHost)) as IDesignerHost;
IComponent componentHost = host.RootComponent;
if (componentHost is ContainerControl)
{
ContainerControl = componentHost as ContainerControl;
}
}
}


So, what is this really doing? If you read in MSDN about this property and its interface type, there's a good chance you'll be scratching your head in confusion. The example in MSDN is of little help.


The containing Form (which has an IContainer in this instance) sets the Site property upon creation of the component. The ISite interface derives from IServiceProvider, which contains the method called above (GetService). None of the methods on ISite provide access to the containing control, so a different technique is needed.


Using the GetService method, an object (service) implementing the IDesignerHost interface is retrieved. Once this object is available, we're almost there! Using the IDesignerHost interface, the RootComponent is accessed and cast to an IComponent. The RootComponent is the WinForm for the active designer. If the root component is a ContainerControl, we cast it and store it away in our property.


Once you have compiled this new component (from a separate assembly to make using it within Visual Studio .NET more convenient) and added it to the toolbox, the component is ready for its first test. Place an instance onto a WinForm (or UserControl) (either drag and drop or double-click the component). Check the properties: the ContainerControl property is set to the host!


If you look at the other ISite interface methods, you may wonder why none of those were used. In this case, the values retrieved from those methods represent objects that are owned by the form, not the actual instance of the form (it has the values/interfaces, not "is a" value/interface).


That's it. Enjoy!

Help support my web site by searching and buying through Amazon.com (in assocation with Amazon.com).