我刚从一位只在一个实时环境中工作过的Sharepoint开发人员那里接手。
我想建立一个开发环境(以及随后的UAT环境),为此,我需要一个确切的(或尽可能接近的)实时版本的克隆,包括所有网站集,内容和(理想情况下)权限。
我使用Google搜索并发现您可以使用Management Shell备份和恢复单个网站集,但单独执行每个集合将非常耗时。
有人能建议一种可靠的方法吗?
答案 0 :(得分: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管理单元,但我会将此由您决定,以确定您的最佳状态。