Followers

Thursday, April 15, 2010

Automated backup In Sharepoint

After so much hard work, once you put your site up and running the only thing which worries you is take the regular backups of your site.

If you have a MOSS 2007 installed on your windows 2003/2008 server then there are two steps you need to take care of:

1) ask your IT department to take the mirror image of the server (with installed softwares periodically). There are few softwares available to achieve this.

2) take the backup of all the sites and the content databases which you have created.

As you know, if you go to the central admin-->operations-->backup and restore--> you will find the option of 'backup'. Its so easy isn't it? The thing is, MOSS 2007 does not let you automate the backup process. I mean what if you want to take the backup everyday at one particular time? There is no way currently available in SharePoint central admin to achieve this. So, here I am, coming to the rescue, and writing down this post.

This time I am not alone I am going to take some references from the Technet and other bloggers.

A. create a folder in the c:/ name it "backup_restore"

B. Share this folder and give full permission. (I bet you know how to do that!)

C. Write a batch file which uses 'stsadm' to take the full backup. (you can select the differential backup too, in my case it takes only few minutes to take the full backup, so I used full backup, with -overwrite option) (Ref: Microsoft Technet)

c.1 Click Start, and then click Run.

c.2 Type notepad, and then click OK.

c.3 In Notepad, type the following text:

##################################################################################

@echo off

echo ===============================================================

echo Back up sites for the farm to C:\backup_restore

echo ===============================================================

cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN

@echo off

stsadm.exe -o backup -directory "C:\backup_restore" -backupmethod full -overwrite

echo completed

###################################################################################

c.4 In Notepad, on the File menu, click Save As.

c.5 In the Save As box, select the folder where you want to keep your batch file.

c.6 Using the ".bat" file name extension, type the name of the file in the File name box, for example, backup_batch.bat.

c.7 In the Save as type box, click All files.

c.8 Click Save.

D. Right click on that file and click on open, it will run a script written in a batch file. Most-likely you will get an error : "BACKUP failed to complete the command BACKUP DATABASE SSO. Check the backup application log for detailed messages."

solution: open the SQL server where your content database is stored and create one empty database named 'SSO', run the script again and It will not prompt for any error.

E. Schedule a backup (Ref: Microsoft Technet)

e.1 Start the Scheduled Task Wizard, and then click Next.

e.2 Click Browse, navigate to the batch file that you just created, and then click Open.

e.3 Type a name for your task, for example, backup_batch.

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

e.5 To automatically perform this backup periodically, select an interval such as Weekly or Monthly. To perform this backup one time, or to delay a single backup, select One time only.

e.6 Choose a time and start date for your backup.

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

e.8 Click Finish.

F. so, its that easy huh??!!(took 4 hours to put all these together!) Its a good practice that when you take a backup, no one is changing anything in the site, otherwise, there is a possibility that you will get corrupted backup which may not be restored successfully. Follow this link:

http://technet.microsoft.com/en-us/library/cc262811.aspx It will guide you how to apply a read only lock on your sites for the period of time when you are taking backups.

G. Its a good practice to store the files to a different server, I am working on that stuff (Take the SP backup to a different server using FTP) and will add to this post soon.

Enjoy!!!!!!!!!!

No comments: