we do have a standard powershell cmdlet, that helps us in taking the back up of farm using backup-spfarm cmdlet.
We could do the job on a dialy or weekly basis with power shell script and windows task scheduler.
After I searched for some time , I got an excellent blog from http://sharepointpolice.com/ .
Here is the same script , I used for my farm.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsofot.SharePoint.Powershell -erroraction silentlycontinue | |
try | |
{ | |
--create the directory with the today's date | |
$today=Get-Date -format "dd-MM-yyyy" | |
[IO.Directory]::CreateDirectory("\\SPQABackup\$today") | |
Backup-SPFarm -directory SPQABackup\$today -Backupmethod full | |
$emailfrom="homeq@domain.com" | |
$emailto="emilgroup@domain.com" | |
$subject="Farm backup schedule updated "+$today | |
$body="The sharepoint QA farm back up was successfull for "+$today | |
--check central admin for outbound email settings and get that adderss here | |
$smtpserver="mailhost.domain.com" | |
$smtp=new-object Net.Mail.Smtpclient($smtpserver) | |
$smtp.send($emailfrom,$emailto,$subject,$body); | |
} | |
catch | |
{ | |
$errormessage=$_.Exception.Message | |
$emailfrom="SPAdmin@domain.com" | |
$emailto="people@domain.com" | |
$subject="Farm Back up schedule status "+$today | |
$body="The sharepoint QA farm back up was failed for "+$today+" "+$errormessage; | |
$smtpserver="mailhost.domain.com" | |
$smtp=new-object Net.Mail.Smtpclient($smtpserver) | |
$smtp.send($emailfrom,$emailto,$subject,$body) | |
} |
No comments:
Post a Comment