4Oct/110
Multi Day SharePoint Services 3 batch file backup w/email reporting
I created a batch script to backup SharePoint Services 3 and email a backup report to my email address. I know there is VBScripts out there that do the same thing but I wanted to create a batch file that backs up SharePoint with retention and email reporting as it would be easier for others to modify that don't know VB.
Key Features
- Backs up SharePoint to c:\spbackups
- Copies the backup files to a remote server
- Keeps a 7 days retention of SharePoint backups
- Emails you a backup report stating the backup has completed successfully
- Lists all backup files in the backup folder and on the remote server within the backup report email
- Lists all files on the remote server
- Uses MAILSEND to email you a backup report
Here is the script
echo SharePoint Services 3 - 7 Day Command Line Backup Script echo Created by: Mike Brawley echo Website: http://www.mikebrawley.com REM ########################################################################## REM REM This script will backup Microsoft SharePoint with 7 days of retention REM Before the backup begins it renames your old backups to archive them REM After the backup has finished it will copy the backup to a remote server REM When the backup is finished it will email you a log with the directory list REM of both the local and remote versions of the backup files REM REM ########################################################################## REM REM Configure all parameters set below REM REM ########################################################################## set location=c:\spbackups set remotelocation=\\server\share\folder set relayserver=smtp.server.com set yoursite=https://sharepoint.yourcompany.com set templog=c:\spbackups\spbackuplog.txt set file=SPBackup.bak set emailsub=SharePointBackupReport set domain=yourcompany.com set to=you@yourcompany.com set reply=noreply@yourcompany.com set STSADM=C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\BIN\Stsadm.exe REM ########################################################################## REM REM Do not edit below this point REM REM ########################################################################## del %location%\%file%.7day rename %location%\%file%.6day %file%.7day rename %location%\%file%.5day %file%.6day rename %location%\%file%.4day %file%.5day rename %location%\%file%.3day %file%.4day rename %location%\%file%.2day %file%.3day rename %location%\%file%.1day %file%.2day rename %location%\%file% %file%.1day "%STSADM%" -o backup -overwrite -url %yoursite% -backupmethod full -filename %location%\%file% > %templog% del %remotelocation%\%file%.7day rename %remotelocation%\%file%.6day %file%.7day rename %remotelocation%\%file%.5day %file%.6day rename %remotelocation%\%file%.4day %file%.5day rename %remotelocation%\%file%.3day %file%.4day rename %remotelocation%\%file%.2day %file%.3day rename %remotelocation%\%file%.1day %file%.2day rename %remotelocation%\%file% %file%.1day XCOPY %location%\%file% %remotelocation% dir %location% >> %templog% dir %remotelocation% >> %templog% MAILSEND -d "%domain%" -smtp "%relayserver%" -t "%to%" -f "%reply%" +cc +bc -sub "%emailsub%" -m "%templog%,text/plain" -a "%templog%,text/plain"
Instructions
- Download the Backup Script Files
- Extract its contents to c:\ on your SharePoint server
- Navigate to C:\SPTools\ and open SPBackup.bat in a text editor. (I recommend Notepad++)
- Set all parameters within SPBackup.bat for your specific SharePoint
- Create a task in Task Scheduler to run this script daily.
- If you would like to push your SharePoint backup offsite you can add C:\SPBackup to your online backup selection list. (I recommend Backup Planet for online backup)
Please feel free to modify and distribute this script in anyway you like.





