We have some low traffic websites hosted in azure. Backups are important to us, but only available on the Standard web hosting plan. So we created a webjob to do it.
Following Eduardo Laureano‘s post the plumbing was soon done. We modified the code to upload a zipfile and we’re done. Some of the changes in code block below.
// format filename as AzureBackup would string backupName = string.Format("{0}_{1}.zip", websiteName, DateTime.Now.ToString("yyyyMMddHHmm")); string zipFile = Path.Combine(Path.GetTempPath(), backupName); // ZipFile is in System.IO.Compression.FileSystem ZipFile.CreateFromDirectory(DIRECTORY_TO_BACKUP, zipFile); // Create block blob for zipfile upload CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(backupName); using (var fileStream = File.OpenRead(zipFile)) { blockBlob.UploadFromStream(fileStream); } // Clean up temporary local file File.Delete(zipFile);
The webjobs is scheduled to run every week. Now we get weekly backups of our files. Not as nice as Microsoft does it with fancy restore, database include and xml listing of files, but it suits our needs.
References
- Eduardo Laureano‘s post that has the plumbing code for my webjob
- Introducing Windows Azure WebJobs by Scott Hanselman
- How to backup a Web Site running on Microsoft Azure Web Sites post by someone called syntaxc4 🙄
- Azure Friday, video’s about all the good stuff in Azure
- Azure websites, good place to start when learning Azure websites