SharePoint 2010 Site Collection Backup mit 7 Tage Vorbehaltzeit

Ich habe ein Script gebaut, welches alle Site-Collections einer WebApplication als einzelne Dateien speichert und nach z.b. 7 Tagen das älteste Backup überschreibt.

$today = (Get-Date -Format dd-MM-yyyy)
$LiveBackupDir = "\\backup01\sharepoint2010backup"
$SiteCollectionSubDir = "\Site Collections\https\"
$SiteCollectionBackupDir = $LiveBackupDir + $SiteCollectionSubDir + $today
$SiteCollectionBackupDeleteDir = $LiveBackupDir + $SiteCollectionSubDir
[IO.Directory]::CreateDirectory($SiteCollectionBackupDir)
Get-SPWebApplication -Identity sharepoint443| Get-SPSite -limit all| ForEach-<a title="See also Share Point 2010 Suche - keine Ergebnisse bei "nicht Admin" Benutzern" href="http://www.pendingcompletion.de/7/">Object</a>{$FilePath = $SiteCollectionBackupDir + "\" + $_.Url.Replace("https://","").Replace("/","-") + ".bak" ; Backup-SPSite -Identity $_.Url -Path $FilePath -UseSqlSnapshot}

$days = 7
$Now = Get-Date
# Notice the minus sign before $days
$LastWrite = $Now.AddDays(-$days)
Get-ChildItem $SiteCollectionBackupDeleteDir |Where {$_.LastWriteTime -le "$LastWrite"}|remove-item -recurse

 

Related Posts

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Switch to our mobile site