The STSADM command is a very important one for anyone managing a SharePoint 2007 / WSS 3.0 server.
The command must be run as an administrator on the server and is (usually) located here : %CommonProgramFiles%\microsoft shared\web server extensions\12\bin or commonly called “the 12 hive”.
With this command you can almost completely manage your server, and perform actions or tasks that you are not able to do through the Central Administration site. Examples are: Import /export sites,
Tip! You can add this folder to your servers’ environment variables. This way, the command can be run from anywhere on the server.
Here are some commands that come in handy:
Backup
stsadm.exe –o backup –url SITEURL –filename BACKUPFILENAME –overwrite -backupmethod <full or differential>
(where –overwrite and –backupmethod are optional parameters)
When the url parameter is used, a backup of the site collection is created. However when the backupmethod parameter is used, a backup of an individual database, Web application, or the entire farm can be created. If you want to overwrite an existing backup file for a site collection only, use the overwriteparameter.
* Preferably, only do this when your site is not used. Usage can/could lead to corruption of your database backup.
There are a couple of limitations to this command:
- A farm backup cannot be used to restore the configuration database or Central Administration content database.
- Site collection backups affect performance, and they can cause access errors. They should only be used when the site collection is locked. Site collection backups can be slow when working with collections larger than 15 GB. This problem seems to have been resolved in WSS SP1. the backup command will first lock the site collection.
I do suggest that you use SQL Management studio (Express) to backup your content database.
Restore
stsadm.exe –o restore –url SITEURL –filename BACKUPFILENAME –overwrite –restoremethod <overwrite or new>
When the url parameter is used, a restoration of the site collection is performed. However, when the restoremethod parameter is used, a restoration of an individual database, Web application, or the entire farm can be performed. If you want to overwrite an existing site collection, use the overwrite parameter.
* Preferably, only do this when your site is not used. Usage can/could lead to corruption of your database backup.
* I do suggest that you use SQL Management studio (Express) to backup your content database.
Export
stsadm.exe –o export –url SITEURL –filename FILENAME –overwrite -includeusersecurity
(where –overwrite and –includeusersecurity are optional)
With this command you exports site and sub site data from your site collection.
Import
stsadm.exe –o import –url SITEURL –filename FILENAME -includeusersecurity
(where –includeusersecurity is optional)
Imports site and subsite data into your site collection.
Note on backup up:
It is recommended to use import/export and backup/restore in he folowing ways:
Import/export: Backups of portions of a site
Backup/restore: Full site collection Backups
Rename a sub site URL
stsadm.exe –o renameweb –url SITEURL –newname NEWSITENAME
Careful, this just changes the URL of a subsite
Rename Site
stsadm.exe –o renamesite –oldurl OLDSITEURL –newurl NEWSITEURL
This command changes the URL of a host-named site collection to a new URL.
Repair Database
stsadm.exe –o databaserepair –url SITEURL –databasename DATBASENAME –deletecorruption
(where –deletecorruption is optional. you should run the command first without, to see if any repairs can be made)
This command detects and removes orphaned items from content databases in Windows SharePoint Services. In some situations, a content database that is used by Windows SharePoint Services may become corrupted. The corrupted database may contain orphaned items.
The databaserepair operation can detect and repair database corruption for only the following types of orphaned items in a content database:
-
A list that does not have a parent Windows SharePoint Services Web site
-
A document that does not have a parent document library
-
A list item that does not have a parent list
-
A Web page that does not have a parent Windows SharePoint Services Web site
Other types of corruption will not be repaired.
Add a solution
stsadm.ex -o addsolution –filename
This command is used to import a WSP solution package. Most of the time these are webparts that you can get from 3rd parties. An example is the RSS ticker web-part from Amrein Engineering.
Technorati Tags: WSS