Saturday, February 28, 2009

STSADM : A tool I can't live with out!

STSADM is a command-line tool that comes with SharePoint to help performing many administration tasks. I said administration tasks! What’s the use of the Central administration interface then? Certainly, almost all the SharePoint administration is done via the this interface but still there are some few tasks that only STSADM can perform. That’s why it’s very important to learn how to use this tool.

Furthermore, what is interesting about STSADM, and since it is a command-line tool, is that we can group many commands in a batch file to execute them all together. We can even schedule the execution to run at a specific time.

STSADM default location is in the BIN directory under the 12 hive: “c:\program files\common files\microsoft shared\web server extensions\12\bin”. To make things easier for your self, add this location to your path variable, so you can execute stsadm.exe anywhere on your command prompt.

As an example (a very simple one), here is a sample of a batch file to perform a backup of a SharePoint site:

Use Notepad or your favorite texte editor and write in the line below:

stsadm.exe -o backup -url %1 -filename c:\backups\%2.bkp

Save this to sitebackup.cmd for example.

As you see, this command file accepts two parameters: %1 and %2. The first parameter is the url of the site to backup and the second is the name you want to give to your backup file.

On the command prompt, enter the following:

sitebackup.cmd http://yoursharepointsiteurl yourbackupfilename

As a result, you will have a backup of your site http://yoursharepointsiteurl.com stored in c:\backups\yourbackupfilename.bkp.

If you want this backup to be performed periodically, just create a scheduled task to execute at any time you want, the command file you have created.

One last thing : STSADM comes with about a hundred of commands that cover many administration tasks. However, if you find that none of these commands can achieve that task you want and of course, this task cannot be done via the central admin, you can develop your own STSADM command and add it to SharePoint. It is very easy and I will show you that in my next post. Until then, try to get acquainted with STSADM commands and enjoy this powerful tool.


Extending STSADM...Develop your own commands : Part 1


No comments:

Post a Comment