Backup IIS Server Package to Amazon S3 using C#
I recently updated our backup process at work to store our backups on Amazon S3. I wanted a simple process to that would backup the IIS server configuration and website files that can be easily be restored on a new server in case of a major problem. Luckily Microsoft have release MSDeploy which can be installed using the Web Platform Installer.
Within IIS you can backup everything to a server package by opening the context menu selecting depoy, then “Export Server Package”. This will create the server package containing the IIS configuration along with all the sites and their files. This is all good however it is still a manual process that is likely to be forgotten about after a while. Likely there are a series of libraries we can use to automate this process.
The namespace Microsoft.Web.Deployment provide the functionality we need to backup IIS, this is provided by Microsoft.Web.Deployment.dll. To backup the server we need to use the DeploymentManager to create an object use to create the package, we can then use this to “sync” the server setting to a package.
After we have backed up the site package we need to upload it to Amazon S3. To do this we can use the AWSSDK .NET library. The library can be installed via NuGet by searching for “AWS SDK”. This will install the required assemblies.
We can use the AWS SDK to upload our server package zip to S3 using the TransferUtilityUploadRequest to create our request to use with the TransferUtility to upload our file.
When this is all tied together we have an app that will backup and upload the server package to S3.
I have attached a sample app that can be configured using the App.config





















John 3:53 pm on March 22, 2011 Permalink |
Thanks for this post! I ran into the same problem. This seems a little odd to me, have you figured out why MVC3 is exhibiting this behavior?
John 4:13 pm on March 22, 2011 Permalink |
Figured out what is going on… this serverfault answer is the perfect explanation:
http://serverfault.com/questions/137073/401-unauthorized-on-server-2008-r2-iis-7-5
In my case, I had a logon page calling Html.RenderAction(), and that action had an [Authorization] attribute.
Cheers.
John 4:17 pm on March 22, 2011 Permalink |
Sorry… [Authorize]
John 8:24 pm on March 22, 2011 Permalink |
Cheers for the update, I’ll have to take a closer look I also have numerous Html.RenderAction() that properly implemnt the [Authorize] attribute.
However I only noticed it since MVC3 RC, I don’t think it was in either of the previous of the beta versions.