Tuesday, June 24, 2008

Automate the backup process by using a batch file (Microsoft Office SharePoint Server 2007)

Hi All,

I came across a very good article on Backup Process for a MS office SharePoint Server 2007. Below is a gist of the same.

It is not possible to schedule backups from the SharePoint Central Administration Web site. There is no operation that enables you to automate backups by using the Stsadm command-line tool. You can, however, automate the process by creating a batch file and then using Task Scheduler in Microsoft Windows Server 2003 to run the batch file at a specific time. Because performance can be affected when doing backups with the Microsoft Office SharePoint Server 2007 built-in tools, you might want to schedule your backups for off-peak times such as at night or on weekends.

Create a batch file to perform a backup of Office SharePoint Server 2007
Use this procedure to create a batch file that will run a full backup of your Office SharePoint Server 2007 server farm. This procedure assumes that you have already created a shared folder for your backups. For more information about how to create a shared folder, see the following article Prepare to back up Office SharePoint Server 2007.

To create a batch file

1. Click Start, and then click Run.
2. Type notepad, and then click OK.
3. In Notepad, type the following text:

@echo off
echo ===============================================================
echo Back up sites for the farm to D:\backupSharePoint
echo ===============================================================
@SET STSADM="c:\program files\common files\microsoft shared\web server extensions\12\bin\stsadm"
cd c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN
@echo off
md "%DATE:/=_%"
%STSADM% -o backup -directory "D:\backupSharePoint\%DATE:/=_%" -backupmethod full -overwrite
echo completed



Note : Change "C:\backup" and "\backup" to the name of your backup shared folder.


4. In Notepad, on the File menu, click Save As.
5. In the Save As box, select the folder where you want to keep your batch file.
6. Using the ".bat" file name extension, type the name of the file in the File name box, for example, backup_batch.bat.
7. In the Save as type box, click All files.
8. Click Save.


Use Task Scheduler to run a batch file that backs up Office SharePoint Server 2007

Use this procedure to schedule backups of your Office SharePoint Server 2007 server farm in Task Scheduler.

Because system performance can be affected when you do complex operations such as backups with the Office SharePoint Server 2007 built-in tools, you might want to schedule your backups for off-peak times, such as at night or on weekends.

To schedule a backup

1. Click Start, and then click Run.

2. Type control, and then click OK.

3. Double-click Scheduled Tasks.

4. Double-click Add Scheduled Task.

5. When the Scheduled Task Wizard appears, click Next.

6. Click Browse, and then browse to and select the batch file that you just created. (See IMAGE-1)



7. Click Open.

8. Type a name for your task, for example, backup_batch. (See IMAGE-2)



9. Select how often you want this task performed (for example, weekly), and then click Next.

10. Select a day and time that you want this task to begin, and then click Next.

11. Enter a name and password for a user, and then click Next. This task will run as if it were started by that user.

12. Click Finish. (See IMAGE-3)






Notes
• To perform this procedure, you must be a member of the Administrators, Backup Operators, or Server Operators group, or have been delegated the appropriate authority, on the local computer. As a security best practice, consider using the Run as command to perform this procedure.

• When creating a scheduled task, you must enter a user name and password, either in the Add Scheduled Task Wizard or in the Run as box on the Task tab of the properties dialog box for the scheduled task. When the scheduled task runs, the program runs as if it were started by the user you specified, with that user's security context.

• To open Task Scheduler, click Start, click Control Panel, and then double-click Scheduled Tasks.

• Confirm that the system date and time on your computer are accurate, as Task Scheduler relies on this information to run scheduled tasks. To verify or change this information, double-click the time indicator on the taskbar.

• To configure advanced settings for the task, select the Open advanced properties for this task when I click Finish check box in the final page of the wizard. This opens the properties dialog box for the task when you click Finish. You can then change the program being run on the Task tab, fine-tune the schedule on the Schedule tab, customize settings on the Settings tab, or set user and group permissions on the Security tab.

Reference:
http://technet.microsoft.com/en-us/library/cc262562(TechNet.10).aspx

1 comment:

Anonymous said...

If you run this you'll most probably get an error. Because this script creates directory in 12/bin folder.

script has to edited like:
md "\\intranet\Backup\%DATE:/=_%"

Manu..




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com