Click here to Skip to main content
15,880,608 members
Articles / Hosted Services / Azure

Windows Azure File Backup Service

Rate me:
Please Sign up or sign in to vote.
4.00/5 (5 votes)
15 Mar 2013GPL33 min read 46.6K   65   17   10
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)


Written By
Software Developer (Senior)
United States United States
I enjoy and take seriously the craft of programming, and I improve upon my skills daily. Start day: coffee is always a good idea!

Comments and Discussions

 
QuestionNot an article... Pin
Dave Kreskowiak15-Mar-13 14:30
mveDave Kreskowiak15-Mar-13 14:30 
AnswerRe: Not an article... Pin
jeff00seattle20-Mar-13 19:18
jeff00seattle20-Mar-13 19:18 
GeneralMy vote of 1 Pin
dvptUml19-Jan-13 12:31
dvptUml19-Jan-13 12:31 
File not found
BugRe: My vote of 1 Pin
jeff00seattle15-Mar-13 12:43
jeff00seattle15-Mar-13 12:43 
AnswerRe: My vote of 1 Pin
jeff00seattle15-Mar-13 12:52
jeff00seattle15-Mar-13 12:52 
QuestionFile not found Pin
wscan15-Dec-12 11:27
wscan15-Dec-12 11:27 
BugRe: File not found Pin
jeff00seattle15-Mar-13 12:42
jeff00seattle15-Mar-13 12:42 
AnswerRe: File not found Pin
jeff00seattle15-Mar-13 12:54
jeff00seattle15-Mar-13 12:54 
Question{"The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security."} Pin
sumitk.cadc23-Apr-12 21:40
sumitk.cadc23-Apr-12 21:40 
GeneralMy vote of 5 Pin
member6027-Feb-12 21:48
member6027-Feb-12 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.