$website="mywebsite"# 站点名称 $sourceFolder='D:\Git\publish\mywebsite'# 发布的源文件路径 $url="10.10.0.37" $port="8500" $username="webDeploy"#需要在IIS管理用户中进行创建 $password="test123123" $webDeployFolder='C:\Program Files\IIS\Microsoft Web Deploy V3' $msdeploy=Join-Path-Path$webDeployFolder-ChildPath"msdeploy.exe" $scriptFolder=Join-Path-Path$webDeployFolder-ChildPath"Scripts" cd"$scriptFolder" . .\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 "mywebsite" to enabled Configure-Backups-SiteName"$website"-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-NumberOfBackups8 # 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") # *********配置备份-结束*********
cd"D:\Git\workspace\mywebsite\Admin.NET" dotnet publish -p:PublishDir=D:\Git\publish\Pony-ErFangAudit--arch x64 $website="mywebsite"# 站点名称 $sourceFolder='D:\Git\publish\mywebsite'# 发布的源文件路径 $url="10.10.0.37" $port="8500" $username="webDeploy"#需要在IIS管理用户中进行创建 $password="W#Edc/@WsxPony" $webDeployFolder='C:\Program Files\IIS\Microsoft Web Deploy V3' $msdeploy=Join-Path-Path$webDeployFolder-ChildPath"msdeploy.exe" $scriptFolder=Join-Path-Path$webDeployFolder-ChildPath"Scripts" cd"$scriptFolder" . .\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 "mywebsite" to enabled Configure-Backups-SiteName"$website"-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-NumberOfBackups8 # 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") # StopAppPool: & $msdeploy-verb:sync -allowUntrusted-source:recycleApp -dest:recycleApp="$website",recycleMode="StopAppPool",computerName="https://${url}:${port}/msdeploy.axd?site=$website",username="$username",password="$password",AuthType="Basic" # sync & $msdeploy-verb:sync -allowUntrusted-source:contentPath=$sourceFolder-dest:contentPath="$website/",computerName="https://${url}:${port}/msdeploy.axd?site=$website",username="$username",password="$password",AuthType="Basic"-skip:objectName=dirPath,absolutePath='Configuration'-skip:objectName=dirPath,absolutePath='logs'-skip:objectName=dirPath,absolutePath='wwwroot' # StartAppPool: & $msdeploy-verb:sync -allowUntrusted-source:recycleApp -dest:recycleApp="$website",recycleMode="StartAppPool",computerName="https://${url}:${port}/msdeploy.axd?site=$website",username="$username",password="$password",AuthType="Basic"