0

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

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

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

谁能建议一种可靠的方法来做到这一点?

4

1 回答 1

0

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

[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 管理单元,但我将由您来决定哪种方式最适合您的情况。

于 2012-12-06T16:09:58.817 回答