# SharePoint スナップインを追加
# SharePoint Server 2010 管理コンソールから実行する場合はこの処理は不要
$snapInInfo = Get-PSSnapin | ` Where-Object{$_.Name –eq “Microsoft.SharePoint.PowerShell”}
if ($snapInInfo –eq $null) {
# SharePoint スナップインが追加されていないので追加する
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# 開始時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ開始: $time "
Backup-SPFarm -BackupMethod Full -Directory c:\Backup\Farm -BackupThread 3
# 終了時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ終了: $time "
Add-Content C:\Backup\Log\FarmBck.log -Value "" # 空白行を追加する
# SharePoint Server 2010 管理コンソールから実行する場合はこの処理は不要
$snapInInfo = Get-PSSnapin | ` Where-Object{$_.Name –eq “Microsoft.SharePoint.PowerShell”}
if ($snapInInfo –eq $null) {
# SharePoint スナップインが追加されていないので追加する
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# 開始時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ開始: $time "
Backup-SPFarm -BackupMethod Full -Directory c:\Backup\Farm -BackupThread 3
# 終了時刻を表示
$time = Get-Date
Add-Content C:\Backup\Log\FarmBck.log -Value "バックアップ終了: $time "
Add-Content C:\Backup\Log\FarmBck.log -Value "" # 空白行を追加する
$admin = Get-Credential # リストア権限のあるユーザー名とパスワードを取得
Restore-SPFarm -Directory C:\Backup\Farm -RestoreMethod Overwrite -item `
"ファーム\Microsoft SharePoint Foundation Web Application\Contoso社内サイト" `
-FarmCredentials $admin –RestoreThreads 3 -Force
Restore-SPFarm -Directory C:\Backup\Farm -RestoreMethod Overwrite -item `
"ファーム\Microsoft SharePoint Foundation Web Application\Contoso社内サイト" `
-FarmCredentials $admin –RestoreThreads 3 -Force
Restore-SPFarm -Directory C:\Backup\Farm -ShowTree
Param($URL) # URLパラメータを定義
if ($URL -eq $null) # URLパラメータが指定されない場合はログファイルに書き出して処理を終了
{
Add-Content C:\Backup\Log\SiteBck.log "サイトURLが指定されていません。"
Return
}
# SharePoint スナップインを追加
$snapInInfo = Get-PSSnapin –Name Microsoft.SharePoint.PowerShell
if ($snapInInfo –eq $null)
{
# SharePoint スナップインが追加されていないので追加する
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# 日付と時刻をバックアップファイルの名前とするために
# 現在の日付と時刻を取得
$date = Get-Date
# PowerShell 書式指定でファイル名を定義
$BackupFileName = "C:\Backup\Site\{0:yyyyMMdd-HHmm}.bck" -f $date
Backup-SPSite -Identity $URL -Path $BackupFileName
※PowerShellファイル等から
PowerShell C:\Scripts\BackupSite.ps1 –url http://sp2010/Sites/Contoso
のように実行
if ($URL -eq $null) # URLパラメータが指定されない場合はログファイルに書き出して処理を終了
{
Add-Content C:\Backup\Log\SiteBck.log "サイトURLが指定されていません。"
Return
}
# SharePoint スナップインを追加
$snapInInfo = Get-PSSnapin –Name Microsoft.SharePoint.PowerShell
if ($snapInInfo –eq $null)
{
# SharePoint スナップインが追加されていないので追加する
Add-PSSnapin Microsoft.SharePoint.PowerShell
}
# 日付と時刻をバックアップファイルの名前とするために
# 現在の日付と時刻を取得
$date = Get-Date
# PowerShell 書式指定でファイル名を定義
$BackupFileName = "C:\Backup\Site\{0:yyyyMMdd-HHmm}.bck" -f $date
Backup-SPSite -Identity $URL -Path $BackupFileName
※PowerShellファイル等から
PowerShell C:\Scripts\BackupSite.ps1 –url http://sp2010/Sites/Contoso
のように実行
このページへのコメント
Py0SN4 Appreciate you sharing, great article post.Really looking forward to read more. Really Cool.
wI2sYp I really liked your blog.Much thanks again. Cool.
CqT97V Thanks again for the blog.Much thanks again. Fantastic.
supHr3 Really enjoyed this article post.Really thank you! Keep writing.
koGiJm <a href="http://skqbikruiumy.com/">skqbikruiumy</a>, [url=http://tjrikccjyiux.com/]tjrikccjyiux[/url], [link=http://njpofqrglndb.com/]njpofqrglndb[/link], http://opuioqseuuko.com/