SharePoint administrators need to run regular backups using PowerShell, the STSADM tool or in Central Administration.
Script :
Script :
Add-PsSnapin Microsoft.SharePoint.Powershell –ErrorAction SilentlyContinuetry { $today = (Get-Date -Format dd-MM-yyyy) $backupDirectory = "C:\Backup\DailyBackUp\$today" # Backup file Location $backupFile = "C:\Backup\DailyBackUp\$today\Backup.dat" # Log file location $logFile = "$backupDirectory\BackupLog.log" # Address of the Site Collection to backup $Site = "http://Spserver1:2000" # Location of the Backup Folder if (-not (Test-Path $backupDirectory)) { [IO.Directory]::CreateDirectory($backupDirectory) #New-Item $logPath -type $backupDirectory } # Get backup start date and time $backupStart = Get-Date -format "MM-dd-yyyy HH.mm.ss" # creates a log file Start-Transcript -Path Start-Transcript -Path $logFile # This will actually initiate the backup process. Write-Host Write-Host Write-Host "Backup starting at $backupStart for $Site " Write-Host "******************************************" Backup-SPSite -Identity $Site -Path $backupFile -Force $backupComplete = Get-Date -format "MM-dd-yyyy HH.mm.ss" Write-Host Write-Host Write-Host "Backup Completed at $backupComplete for $Site " Write-Host "******************************************" Stop-Transcript }Catch { $ErrorMessage = $_.Exception.Message write "$today BackUp Failed $ErrorMessage ">>$logFile }
No comments:
Post a Comment