Skip to content
Johan Leino edited this page Jun 17, 2013 · 13 revisions

This module is used when you want to perform a content backup of your IIS site before you deploy a new version to it. Internally it uses the Backup-WDApp Cmdlet and that in itself is just a fancy wrapper around the iisApp Provider.


Hello World

First install via NuGet Install-Package WDP.Backup.

Given that the WDP.Backup.psm1 script file exists in the same direcory from where you execute it here's a basic example that backups a local IIS site called test.xample.com

Import-Module .\WDP.Backup.psm1

Invoke-Backup test.xample.com

The Conventions (the defaults)

Below is a listing of all the conventions (the defaults) that we're using. If you don't like them just change them.

* SourcePublishSettingsFiles ([ string[] ])

default: optional [not set]

We will backup the site on the local IIS server that the script is running on.

If you wish to backup a site on a remote, or several, server this property will contain an array of the paths to .publishsettings files that represents these servers.

* BackupLocation ([ string ])

default: .Backups

We will place all the backups in the current directory + a sub directory called Backups.

* PublishArtifacts ([ bool ])

default: [set by TeamCity]

The default is if the code executes within TeamCity this parameter will default to true. Otherwise it's false.

It controls whether or not the backup file will be published as a build artifact in TeamCity.

* ProviderSettings ([ string ])

default: [not set]

Custom Provider Settings that you can enable. Read more on the iisApp Provider.

* SkipFolderList ([ string ])

default: [not set]

Folders you want to skip. TODO: add example

* SkipFileList ([ string ])

default: [not set]

Files you want to skip. TODO: add example


Changing The Conventions

If you don't like the conventions (defaults) that we have setup you can always change them. The basic idea is that you'd call Set-Properties before invoking the function with a the keys and values you'd like to change.

Example - 1

This example backups a site on two remote servers and doesn't use TeamCity artifact publishing.

Import-Module .\WDP.Backup.psm1

Set-Properties @{
SourcePublishSettingsFiles = @(".\serverA.publishsettings",".\serverB.publishsettings")
PublishArtifacts = $false
}

Invoke-Backup

Important!!

In this situation, where no IIS application is specified as parameter to Invoke-Backup, the .publishsettings files need to include that information. Like this: