【问题标题】:Sharepoint 2010 Clone Entire Web ApplicationSharepoint 2010 克隆整个 Web 应用程序
【发布时间】:2012-11-24 16:12:17
【问题描述】:

我刚刚接手了一位只在单一实时环境中工作的 Sharepoint 开发人员。

我想建立一个开发环境(以及随后的 UAT 环境),因此我需要一个准确(或尽可能接近准确)实时版本的克隆,包括所有网站集、内容和(理想情况下)权限。

我在 Google 上搜索过,发现您可以使用命令行管理程序备份和恢复单个网站集,但单独执行每个收集将非常耗时。

谁能提出一个可靠的方法来做到这一点?

【问题讨论】:

    标签: .net sharepoint sharepoint-2010 clone sitecollection


    【解决方案1】:

    为什么不直接编写脚本呢?这是我使用的一个小脚本:

    [System.Console]::Clear()
    
    write-host "remoting to live environment"
    
    $siteCollectionUrl = "http://live.mysite.com";
    
    if ($args.count -gt 0) {
       $siteCollectionUrl = $args[0]
       write-host "going to pullback content from $siteCollectionUrl"
    }
    
    $pwd = Get-Content c:\install\backups\crd-sharepoint.txt | ConvertTo-SecureString
    
    $crd=new-object -typename System.Management.Automation.PSCredential -ArgumentList "dev\svc-sp-setup-dvt", $pwd
    
    $s = New-PSSession -computername "liveServer" -Authentication CredSSP -Credential $crd
    
    Invoke-Command -Session $s -Scriptblock {
    param($siteCollectionUrl)
    write-host "Connected, activating SharePoint snap-in..."
    Add-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction "SilentlyContinue"
    
    write-host "Backing up $siteCollectionUrl remotely..."
    backup-spsite -identity "$siteCollectionUrl" -path "c:\install\backups\scheduled_backup.bak" -force
    } -args $siteCollectionUrl
    #end session
    Remove-PSSession $s
    
    $path = "c:\install\backups\"
    write-host "Copy backup locally..."
    #copy
    copy-item "\\liveServer\c$\install\backups\scheduled_backup.bak" $path -Force
    
    write-host "restore...this may take a while if not already running in SharePoint PowerShell.  your patience is appreciated"
    #restore
    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
    
    restore-spsite -identity "$siteCollectionUrl" -path c:\install\backups\scheduled_backup.bak -force -confirm:$false
    
    $username = [Environment]::UserName
    
    write-host "have a great day, $username"
    

    这确实需要启用 PowerShell 远程处理。如果您有一个站点列表,您可以简单地使用您想要复制的站点集合的 URL 重复调用此脚本,例如

    $scriptPath = Join-Path (get-location) "backup_and_restore.ps1";
    & $scriptPath "http://admin.accounting.mycompany.com"
    & $scriptPath "http://admin.sales.mycompany.com"
    & $scriptPath "http://admin.marketing.mycompany.com"
    & $scriptPath "http://admin.engineering.mycompany.com"
    

    或者,您可以在脚本中为每个网站集创建一个备份,然后以实物形式恢复它们。这将大大提高效率,因为您不必重新启动 SharePoint 管理单元,但我将由您自己决定哪种方式最适合您的情况。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-18
      • 1970-01-01
      相关资源
      最近更新 更多