Quantcast
Channel: Jonathan Vasquez » SharePoint
Viewing all articles
Browse latest Browse all 2

Scripting SharePoint Site Collection Backups

$
0
0

I ran into a situation where I needed to automate the backup procedure for a site collection and then move the backup to another server where all of our backups are stored. I figured that doing this manually would be the simplest way; however, backups run at midnight which made it hard ofr me to perform the task manually. Faced with this impediment, I decided to script the back up and moving process, and use Blat to send an automated e-mail once the backup was complete.

The code for the BAT file is below along with an explanation fo the code. This scripted backup creates a full backup of the entire site collection and saved the backup files in a different folder each day based on the date. Once the backupo is complete it sends an e-mail to the desired user or group of users. You will need to download and configure Blat for the last part of the script to be successful. Alternatively, you can delete the Blat command from the batch file.

@echo off
echo ===============================================================
echo SharePoint Site Collection Backup Utility
echo ===============================================================
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
cd c:\folder
@echo off
md "%DATE:/=_%"
%STSADM% -o backup -directory "\\tempserver\folder\%DATE:/=_%" -backupmethod full -overwrite
@echo off
echo ===============================================================
echo ===============================================================
echo COPYING FILES TO BACKUP SERVER
echo ===============================================================
echo ===============================================================
xcopy c:\folder\*.* \\backupserver\backupfolder\Intranetbackup\*.* /s
echo ===============================================================
echo ===============================================================
echo DELETING ORIGINAL FILES
echo ===============================================================
echo ===============================================================
rd /s /q c:\folder\"%Date:/=_%"
cd "C:\Desktop\Sp Backup Tool"
echo ===============================================================
echo ===============================================================
echo PREPARING TO E-MAIL ADMINISTRATOR
echo ===============================================================
echo ===============================================================
blat -to me@mycompany.com -s "Sharepoint Server Backup Complete" -body "Backup Complete"
echo completed


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images