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:
- 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.
- Windows Form application for backup configuration.
- Windows Service to automatically perform the file backup operation based upon provided backup configuration.
- Windows Service Installer
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.
The solution sources are also available within CodePlex: Windows Azure File Backup Service
- 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
- 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
- Determine Relative Path
- WindowsAzure_FileBackup_Console -- Windows Form application
- 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
- Install, but do not Start, WindowsAzure_FileBackup_Service using Setup. It should appear within Services named "Windows Azure File Backup".
- Create two directories:
- Backup Directory: e.g., F:\WindowsAzureBackupFolder
- Recovery Directory: e.g., F:\WindowsAzureRecoveryFolder
- Start WindowsAzure_FileBackup_Console
- 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.
- Start Service now because configuration settings are available.
- You need to provide a valid Storage Account Name and Key, or the Windows Service will fail.
- Events are logged within:
- LogName: WindowsAzureFileBackup
- LogSource: Service or Console
- All configuration setting are registered within: HKEY_LOCAL_MACHINE\SOFTWARE\jeff00seattle\WindowsAzureFileBackup
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:
- Microsoft Fix-It -- Fix problems with programs that can't be installed or uninstalled.
- Uninstall Tool -- Ultra fast and small utility that helps you to uninstall various software.
- 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.
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.