Rexxer

Some tips for me and other

SharePoint 2010 backup

Backup-site.ps1

Add-PSSnapIn Microsoft.SharePoint.PowerShell
$backupdestination = “//server/SharePoint_BackUp/”
[int] $HistoryDays = 5
[int] $minusHistoryDays = -5

#Verify if more then 10 backup exist, old can be deleted
$a = dir $backupdestination |? {$_.name.EndsWith(‘.backup’)}
if($a.count -gt $HistoryDays)
{

#Delete old files
$DelDate = (Get-Date).AddDays($minusHistoryDays)
dir $backupdestination |? {$_.CreationTime -lt $delDate -and $_.name.EndsWith(‘.backup’)} | del -force
}

#Create new backup
$siteName=”http://spserver/sites/Documents”
$TodayDate = Get-Date -format D
$BackUpFileName = $backupdestination + “SiteDocuments_$TodayDate.backup”

Backup-SPSite -Identity $siteName -Path $BackUpFileName  -Force

Backup-Farm.ps1

Add-PSSnapIn Microsoft.SharePoint.PowerShell
Backup-SPFarm -Directory \serverSharePoint_BackUp -BackupMethod full

Leave a Reply