How do I backup Companyweb if I do not have a full version of SQL installed?
When dealing with Companyweb database issues, this is a very common question. Unfortunately the conversation usually takes place after replacement SharePoint databases cannot be accessed or the data found in these databases is missing or corrupt. Often the only type of “backup” a customer may have are copies of the Companyweb databases that have been saved either through NTBackup or some other backup application. In cases that deal with corrupt databases, having copies of these databases is better than nothing, however backing up SharePoint databases should not be considered a “Best Practice” when considering a backup solution for Companyweb data.
What is STSADM.exe
The STSADM.exe tool is specifically designed to backup and restore SharePoint websites and their sub-sites among other things. This tool provides a method for performing SharePoint administration tasks at the command line or by using batch files or scripts. This command-line tool allows you to perform the same tasks found in the Central Administration website, along with other operations and certain parameters that are only available by using the Stsadm command-line tool (these options will not be covered in this particular blog).
Before we Proceed:
If you are using a full version of SQL Server 2000 or SQL Server 2005, using the stsadm.exe utility as the primary backup and restore solution for Windows SharePoint Services is not recommended. Instead, it is recommended that you use the backup tools included with SQL Server for your SharePoint backups.
STSADM.exe – using the Backup and Restore function:
1. The STSADM.exe utility, gives the Administrator the ability to back up and restore individual Web sites hosted on Small Business Server 2003.
2. The tool is used/executed through the command-line and can be found in the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin (%COMMONPROGRAMFILES%\microsoft shared\web server extensions\60\bin).
3. You must be a member of the server computer's administrators group or a member of the SharePoint administrators group to be able to back up or restore a site.
What does STSADM.exe backup?
1. The content database for the site.
2. All pages in the site.
3. Files in document libraries or lists.
4. Security and permission settings.
5. Feature settings.
Benefits of STSADM.exe
- The STSADM.exe backup and restore method allows you to replace a site that has become corrupt, or that contains changes that need to be rolled back.
- You can then restore your site to either the same location or to a new location. (Do not confuse this with the migration of SharePoint sites. Smigrate is still the recommended tool for migration situations)
- The backup file for a top-level Web site includes any sub-sites of that site.
- This backup and restore method is not dependent on the type of database you are using.
- You can perform this backup and restore method even if you are running Microsoft SQL Server 2000 Desktop Engine (Windows) (WMSDE) instead of Microsoft SQL Server 2000 or SQL Server 2005.
- If you need to back up a specific site, rather than a whole installation of Windows SharePoint Services, you can do so by using the backup and restore operations with the Stsadm.exe command-line tool.
- You can automate the backup process by using a batch file, a script, or the Scheduled Tasks item on Microsoft Windows Control Panel.
Things to consider before starting/creating a backup job.
- STSADM backup and restore are not designed to be used when the server is under active load.
- The process of backing up and restoring sites takes up both memory and processing power on your server.
- If a site is in use when the backup operation is run, the data in that site may continue to change throughout the operation. The resulting backup file may be inconsistent with the actual state of the site and, if you restore this file, the restored site or database will be inconsistent as well.
- To avoid possible inconsistencies, lock the site collection prior to backing to starting the backup.
- After the backup is complete, set the lock back to "Not locked". For information about locking and unlocking a site collection, see the Managing Locks section of the Configuring Site Collection Quotas and Locks (Windows SharePoint Services 2.0) topic.
- The process of backing up and restoring sites takes up both memory and processing power on your server. In addition, if you have many sites, or a large amount of data in your sites, the backup process can take a long time, and might result in access errors for your users
Creating a “Manual” backup using STSadm.exe:
1. Create the folder or share where you would like to store the Sharepoint Backups
3. From a command prompt navigate to the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin (%COMMONPROGRAMFILES%\microsoft shared\web server extensions\60\bin folder
4. Enter the command stsadm.exe -o backup -url http://companyweb -filename c:\backup\backup.dat -overwrite
6. Insure the backup has been created
Creating a “Scheduled” backup using STSadm.exe with a .vbs script - KB829112:
Here is the .vbs script found in KB829112. The script was written by David Copeland, who also wrote the "Small Business Server Best Practices Analyzer". If your not using this already, "Shame on You" :). This utility can cut down on hours of Troubleshooting, and should be in every Small Business Server consultants "toolbox". http://www.microsoft.com/downloadS/details.aspx?familyid=3874527A-DE19-49BB-800F-352F3B6F2922&displaylang=en
Here's David's script:
dayweek = datepart("w",(date))
strBackup = """C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN\stsadm""" + _
"-o backup -url http://companyweb -filename x:\backups\companyweb" + cstr(dayweek) + ".dat -overwrite"
Set WshShell = WScript.CreateObject("WScript.Shell")
Return = WshShell.Run(strBackup, 0, true)
Set WshShell = Nothing
Creating a “Scheduled” backup using a batch file:
1. Create a new .txt file in the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin path
2. Copy the script below into the .txt file - DOS Script
If you are not as familiar with .vbs scripting as you would like to be, here is a DOS script that will help you create the backup as well.
echo Backup Script For Http://companyweb
cd \program files\common files\microsoft shared\web server extensions\60\bin
stsadm.exe -o backup -url http://companyweb -filename c:\backup\backup.dat -overwrite
3. If using the DOS script, save the .txt file as CompanywebBackupScript.bat. If using David's script please save it with a .vbs extension.
4. Verify the CompanywebBackupScript.bat file is in the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin folder
5. Create a scheduled task to execute the backup script
6. Start\All Programs\Accessories\System Tools\Scheduled Tasks\Add Scheduled task
8. Select Browse
9. Browse to \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin\ CompanywebBackupScript.bat
10. Select Open
11. Type a name for the task.
12. Select the frequency you would like the task to run - Next
13. Select Start time and Start date – Next
14. Enter in an account that the process can run under – preferably an administrator account if possible
15. Next – Finish
16. Test the Scheduled task
17. Rt-Click the newly created task – select run
18. Insure the backup was created – Review the backup folder
19. Insure the Backup.dat file is created successfully at the next scheduled execution time.
How do I restore an STSADM.exe backup
1. Move the \Program Files\Common Files\Microsoft Shared\Web Server Extensions\60\bin folder
2. Enter the following command: stsadm.exe -o backup -url http://companyweb -filename c:\backup\backup.dat -overwrite
3. It should return that the "Operation completed successfully".