How to create a batch file to do automatic backup of SharePoint site?

Suppose you have a SharePoint site with some heavy and important data and you want to take the backup regularly. So instead of manual process you can create a batch file which will automatically take the backup of the mentioned site.

Below is the given script:
Write below code in a notepad and save it as .bat file.

@echo off
@echo This script will backup your site: [Enterprise Management Site]
cd C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
@echo locking site collection before the backup process starts
@echo off

stsadm -o getsitelock -url http://moss-server:333/
stsadm -o setsitelock -url http://moss-server:333/  -lock readonly
@echo site collection is now locked
@echo off
stsadm -o backup -url http://moss-server:333/  -filename C:\RRSbackup\autobackup.bak -overwrite @echo backup completed
@echo off
stsadm -o setsitelock -url http://moss-server:333/  -lock none
@echo Site lock removed

Once you ready with your batch file then you can put this batch file in a scheduler and define a time to run this batch file.


Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX