Web 部署自动备份
Web 部署提供了在部署时自动备份目标 Web 站点(而不是目标 Web 应用程序!)的选项。建议允许 Web 应用程序回滚。
要配置自动备份,必须遵循以下步骤:
1)启用备份
在 Powershell 中打开%programfiles%\IIS\Microsoft Web Deploy V3\scripts\BackupScripts.ps1
执行以下命令:
# Turns on all backup functionality
TurnOn-Backups -On $true
# Turns off all backup functionality
TurnOn-Backups -On $false
# Changes default global backup behavior to enabled
Configure-Backups -Enabled $true
# Changes default backup behavior for site "foo" to enabled
Configure-Backups -SiteName "foo" -Enabled $true
# Changes the path of where backups are stored to a sibling directory named "siteName_snapshots".
# For more information about path variables, see the "backupPath" attribute in the section
# "Configuring Backup Settings on the Server for Global usage manually in IIS Config"
Configure-Backups -BackupPath "{SitePathParent}\{siteName}_snapshots"
# Configures default backup limit to 5 backups
Configure-Backups -NumberOfBackups 5
# Configures sync behavior to fail if a sync fails for any reason
Configure-Backups -ContinueSyncOnBackupFailure $false
# Adds providers to skip when performing a backup
Configure-Backups -AddExcludedProviders @("dbmysql","dbfullsql")
# Allows a site administrator to enable backups and set the number of backups at the site level
Configure-BackupSettingsProvider -CanSetEnabled $true -CanSetNumBackups $true
# Allows a site administrator to control which providers they want to skip in a backup, as
# well as whether they can continue a sync after a backup failure
Configure-BackupSettingsProvider -CanSetContinueSyncOnBackupFailure $true -CanAddExcludedProviders $true
2)检查全局或站点级别的备份设置
Get-BackupSettings
Get-BackupSettings -SiteName "Default Web Site"
3)进一步的备份定制
可以为每个网站配置备份设置。打开 applicationHost.config
并为其特定位置添加备份设置:
<location path="siteName">
<system.webServer>
<wdeploy>
<backup enabled="true" numberOfBackups="4">
<excludedProviders>
<clear />
<provider name="dbfullsql" />
</excludedProviders>
</backup>
</wdeploy>
</system.webServer>
</location>
有关与命令行使用相关的安全相关信息和其他信息,请访问本文 。