You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何使用Web Deploy迁移应用且不覆盖目标IIS现有站点?

Web Deploy Migration Without Overwriting Target IIS Content

Absolutely! You can migrate your apps using Web Deploy without overwriting existing sites/apps on the target server, and merge the contents of both servers' Default Web Site instances safely. Here are step-by-step approaches tailored to your scenario:

Instead of migrating the entire Default Web Site from the source, export and import only the specific apps you need. This minimizes the risk of conflicting with target content:

Export from Source Server

Use the msdeploy command to export a single app under Default Web Site:

msdeploy -verb:export -source:appHostConfig="Default Web Site/YourTargetApp" -dest:package="YourTargetApp.zip"

Replace YourTargetApp with the name of the app you want to move.

Import to Target Server

On the target server, import the package while ensuring existing content isn't deleted:

msdeploy -verb:sync -source:package="YourTargetApp.zip" -dest:appHostConfig="Default Web Site/YourTargetApp" -enableRule:DoNotDeleteRule
  • The -enableRule:DoNotDeleteRule flag is critical here: it tells Web Deploy to only add or update your migrated app and leave all existing target site/apps/files untouched.
  • If the app name already exists on the target, you can either rename the imported app (e.g., Default Web Site/YourTargetApp_Migrated) or use the -skip rule to avoid overwriting it (see section 2).

2. Merge Entire Default Web Site Contents (Preserve Target Existing Items)

If you need to sync the full Default Web Site from source to target but keep the target's existing content intact, use sync with targeted skip rules:

msdeploy -verb:sync -source:appHostConfig="Default Web Site" -dest:appHostConfig="Default Web Site",computerName=TargetServerName -enableRule:DoNotDeleteRule -skip:objectName=filePath,absolutePath="C:\inetpub\wwwroot\TargetExistingAppFolder" -skip:objectName=appHostConfig,keyAttribute="applicationPath",value="Default Web Site/TargetExistingApp"

Breakdown of key flags:

  • -enableRule:DoNotDeleteRule: Prevents deletion of any existing content on the target.
  • -skip:objectName=filePath: Skips specific directories/files on the target you want to protect (replace the path with your actual target folder).
  • -skip:objectName=appHostConfig: Skips specific existing apps on the target by their application path.

3. GUI Approach (IIS Manager)

If you prefer a visual interface instead of command line:

  • Source Server: Right-click the app under Default Web SiteDeployExport Application Package. Save the zip file.
  • Target Server: Right-click Default Web SiteDeployImport Application Package. Select your zip file.
    • In the import wizard, under Select the import options, check the box for Do not delete extra files on destination (this maps to the DoNotDeleteRule).
    • If the app name already exists on the target, you can choose to skip it or rename the imported app during setup.

Critical Pre-Migration Checks

  • Backup First: Always back up the target server's Default Web Site before making changes:
    msdeploy -verb:export -source:appHostConfig="Default Web Site" -dest:package="TargetDefaultSiteBackup.zip"
    
  • Validate Dependencies: Ensure the target server has matching .NET versions, IIS features, and any custom components (like certificates or third-party modules) required by your migrated apps.
  • Database Sync: If your apps rely on databases, migrate those separately (e.g., SQL Server backup/restore or data sync tools) to avoid overwriting target databases.

内容的提问来源于stack exchange,提问作者Syntax Error

火山引擎 最新活动