Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Hosted-services / Azure

Windows Azure File Backup Service

4.00/5 (5 votes)
15 Mar 2013GPL33 min read 47.5K   65  
Defining a Windows Service to incrementally backup an assigned directory to Windows Azure Blob Storage using Blob REST based upon root directory change notifications to FileSystemWatcher.

Introduction

There have been articles about using Windows Azure Blob Service to backup files; notably Windows Azure's sample "Synchronizing Files to Windows Azure Storage".

However, this "no rocket science" article takes it a step further by defining a complete solution:

  1. C# Libraries for syncing the file contents and their metadata of an assigned root directory to a defined Blob container within a Windows Azure Storage account using Blob Service REST API and System.IO.FileSystemWatcher class.
  2. Windows Form application for backup configuration.
  3. Windows Service to automatically perform the file backup operation based upon provided backup configuration.
  4. Windows Service Installer

Background

I am doing this article as a personal interest to review Blob Service REST API and to see it using Windows Azure Storage as resources for file backup as viable choice.

Code Plex

The solution sources are also available within CodePlex: Windows Azure File Backup Service

Solution Components

  • WindowsAzure_REST -- C# Library
    • Using Blob Service REST API:
      • Create Blob Container as a repository for holding file backup
      • CRUD service of directories and files persisted as blobs
      • Maintain directory and file metadata within each persisted blob
  • WindowsAzure_FileBackup_Common -- C# Library
    • Registering and Maintaining Windows Azure Storage access information
      • Connection Mode
        • Cloud
        • Local
      • Endpoint URL
      • Account Name
      • Account Key
      • Blob Container Name
    • Registering and Maintaining File Backup and Recovery information
    • Defines File Monitor handlers for System.IO.FileSystemWatcher
    • Support Functionality
      • Wrapper functions around aforementioned C# Library WindowsAzure_REST methods.
        • Save File to Blob Service
        • Retrieve File from Blob Service
      • File and Directory methods
        • Gather information to be used by Blob Metadata
          • FileName
          • Attributes
          • CreationTimeUtc
          • LastAccessTimeUtc
          • LastWriteTimeUtc
          • RelativePath
          • PathWithName
          • Size
          • IsDirectory
        • Determine Relative Path
  • WindowsAzure_FileBackup_Console -- Windows Form application
    • Configuration
      • Windows Azure Account Info
      • Backup and Recovery Info
    • Backup Info
      • Number of Files in Backup Directory
      • Number of Blobs in Backup Blob Container
      • Number of Files in Recovery Directory
    • Force Action
      • Complete backup of all files within Backup Directory to Backup Blob Container
      • Complete restore of all files from Backup Blob Container to Restore Directory
  • WindowsAzure_FileBackup_Service -- Windows Service
    • When started, it keeps System.IO.FileSystemWatcher monitoring changes to Backup Directory, and matches those changes within Backup Blob Container.
  • WindowsAzure_FileBackup_Service_Setup -- Installer of Windows Service
    • Service Name: "Windows Azure File Backup"

Using the Code

  1. Install, but do not Start, WindowsAzure_FileBackup_Service using Setup. It should appear within Services named "Windows Azure File Backup".
  2. Create two directories:
    • Backup Directory: e.g., F:\WindowsAzureBackupFolder
    • Recovery Directory: e.g., F:\WindowsAzureRecoveryFolder
  3. Start WindowsAzure_FileBackup_Console
    • Configure
      • Storage Account Name
      • Storage Account Key
      • Backup Blob Container
        • Default "cloudfilebackup"
      • Backup Local Path
      • Recovery Local Path
      • Connection Mode
        • Default "Cloud"
        • "Local" is only available for:
          • Windows 7
          • Windows Vista
          • Windows 2008
    • Select Button "Prepare Backup" to register configuration settings.
  4. Start Service now because configuration settings are available.

336418/WindowsAzure_FileBackup_Console.PNG

Note

  1. You need to provide a valid Storage Account Name and Key, or the Windows Service will fail.
  2. Events are logged within:
    • LogName: WindowsAzureFileBackup
    • LogSource: Service or Console
  3. All configuration setting are registered within: HKEY_LOCAL_MACHINE\SOFTWARE\jeff00seattle\WindowsAzureFileBackup

Helpful Tools

While developing the Windows Service, there were times where reinstalling was required; however, uninstalling would fail. There were two freeware tools that helped out tremendiously:

  1. Microsoft Fix-It -- Fix problems with programs that can't be installed or uninstalled.
  2. Uninstall Tool -- Ultra fast and small utility that helps you to uninstall various software.

In addition:

  • ClumsyLeaf CloudXplorer -- To validate that files were being persisted as blobs within backup blob container, and associated blob metadata as well.
  • Fiddler Web Debugger -- Exceptionally helpful in validating RESTful access to Blob Service.

Recognition

Code Plex project Azure Storage Samples was exceptionally useful by providing a well implemented Blob Service REST API. I had implemented my own, but I found this one and liked it better.

History

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)