2012-12-06 21 views
0

我剛接手一個僅在單一實時環境中工作的Sharepoint開發人員。Sharepoint 2010克隆整個Web應用程序

我想建立一個開發環境(以及隨後也是一個UAT環境),所以爲此我需要一個實時版本的精確(或接近精確)克隆,包括所有網站集,內容和(理想)權限。

我已經谷歌搜索,發現你可以使用管理外殼備份和恢復單個網站集,但單獨做每個集合會非常耗時。

任何人都可以建議一個可靠的方法來做到這一點?

回答

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遠程啓用。如果您有一個網站列表,您可以簡單地使用您想要複製的網站集的網址重複調用此腳本,例如

$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管理單元,但是我將根據您的情況決定什麼纔是最好的。

相關問題