Sharepoint Backup Script
I'm trying to figure out how to backup the Windows Sharepoint Services sites from the command line, but I am finding the documentation online to be lacking.here is the line I'm tryingSTSADM.EXE -o backup -directory Z:\Internal Operations\Information Technology\Backup\SharePoint\BackupFiles -backupmethod fullwhich just returns 'Command line error.' I think it might have something to do with the spaces in the name, so I tried saving it to STSADM.EXE -o backup -directory Z:\Archive\test\test2 -backupmethod fulland it kind of works, except that there are errors. The log file says:[2/26/2007 4:07:10 PM]: Verbose: Using directory: Z:\Archive\test\test2\spbr0000\.[2/26/2007 4:07:10 PM]: Verbose: The backup/restore process included the following objects:[2/26/2007 4:07:10 PM]: Farm\ [SharePoint_Config]\ Windows SharePoint Services Web Application\ SharePoint - 80\ WSS_Content\ [WSS_Administration]\ [Web Application]\ SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9\[2/26/2007 4:07:10 PM]: Progress: Starting Backup.[2/26/2007 4:07:10 PM]: Start Time: 2/26/2007 4:07:10 PM.[2/26/2007 4:07:10 PM]: Verbose: Requested by JLWARRANTY\spps.[2/26/2007 4:07:10 PM]: Verbose: Backup/Restore Settings: Backup Backup Method: Full Top Component: Directory: Z:\Archive\test\test2 Progress updated: 5[2/26/2007 4:07:10 PM]: Backup threads created: 1[2/26/2007 4:07:10 PM]: Verbose: Adding Farm to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding SharePoint_Config to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding Windows SharePoint Services Web Application to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding SharePoint - 80 to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding WSS_Content to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding WSS_Administration to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding Web Application to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Adding SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9 to Backup list.[2/26/2007 4:07:10 PM]: Verbose: Starting OnPrepareBackup event.[2/26/2007 4:07:10 PM]: Verbose: Starting object: Farm.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: SharePoint_Config.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: Windows SharePoint Services Web Application.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: SharePoint - 80.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: WSS_Content.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: WSS_Administration.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:10 PM]: Verbose: Starting object: Web Application.[2/26/2007 4:07:10 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:11 PM]: Verbose: Starting object: SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9.[2/26/2007 4:07:11 PM]: Verbose: Saving SPPersistedObject State[2/26/2007 4:07:11 PM]: Verbose: Starting OnBackup event.[2/26/2007 4:07:11 PM]: Verbose: Starting object: Farm.[2/26/2007 4:07:11 PM]: Progress: [Farm] 50 percent complete.[2/26/2007 4:07:11 PM]: Verbose: Starting object: SharePoint_Config.[2/26/2007 4:07:11 PM]: Verbose: [SharePoint_Config] SQL Server Connection String: Data Source=poweredge1850;Initial Catalog=SharePoint_Config;Integrated Security=True;Enlist=False.[2/26/2007 4:07:11 PM]: Verbose: [SharePoint_Config] SQL command started at: 2/26/2007 4:07:11 PM. This command may take a while to complete and without notification.[2/26/2007 4:07:11 PM]: Verbose: [SharePoint_Config] SQL Server Command: BACKUP DATABASE [SharePoint_Config] TO DISK=@db_loc WITH NAME=@db_name, STATS=5, NOINIT, NOSKIP, NOFORMAT, NOREWIND @db_name=SharePoint_Config, @db_loc=Z:\Archive\test\test2\spbr0000\00000008.bak[2/26/2007 4:07:11 PM]: Error: Object SharePoint_Config failed in event OnBackup. For more information, see the error log located in the backup directory. SqlException: Cannot open backup device 'Z:\Archive\test\test2\spbr0000\00000008.bak'. Device error or device off-line. See the SQL Server error log for more details.BACKUP DATABASE is terminating abnormally.[2/26/2007 4:07:11 PM]: Debug: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.RunCommand(SPBackupRestoreInformation args, Boolean& restart, SPSqlBackupRestoreConnection connection) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.SPDatabase.OnBackup(Object sender, SPBackupInformation info)[2/26/2007 4:07:11 PM]: Verbose: Starting object: Windows SharePoint Services Web Application.[2/26/2007 4:07:11 PM]: Progress: [Windows SharePoint Services Web Application] 50 percent complete.[2/26/2007 4:07:12 PM]: Verbose: Starting object: SharePoint - 80.[2/26/2007 4:07:12 PM]: Progress: [SharePoint - 80] 50 percent complete.[2/26/2007 4:07:12 PM]: Verbose: Starting object: WSS_Content.[2/26/2007 4:07:12 PM]: Verbose: [WSS_Content] SQL Server Connection String: Data Source=poweredge1850;Initial Catalog=WSS_Content;Integrated Security=True;Enlist=False;Connect Timeout=15.[2/26/2007 4:07:12 PM]: Verbose: [WSS_Content] SQL command started at: 2/26/2007 4:07:12 PM. This command may take a while to complete and without notification.[2/26/2007 4:07:12 PM]: Verbose: [WSS_Content] SQL Server Command: BACKUP DATABASE [WSS_Content] TO DISK=@db_loc WITH NAME=@db_name, STATS=5, NOINIT, NOSKIP, NOFORMAT, NOREWIND @db_name=WSS_Content, @db_loc=Z:\Archive\test\test2\spbr0000\0000000A.bak[2/26/2007 4:07:12 PM]: Error: Object WSS_Content failed in event OnBackup. For more information, see the error log located in the backup directory. SqlException: Cannot open backup device 'Z:\Archive\test\test2\spbr0000\0000000A.bak'. Device error or device off-line. See the SQL Server error log for more details.BACKUP DATABASE is terminating abnormally.[2/26/2007 4:07:12 PM]: Debug: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.RunCommand(SPBackupRestoreInformation args, Boolean& restart, SPSqlBackupRestoreConnection connection) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.SPDatabase.OnBackup(Object sender, SPBackupInformation info)[2/26/2007 4:07:12 PM]: Verbose: Starting object: WSS_Administration.[2/26/2007 4:07:12 PM]: Progress: [WSS_Administration] 50 percent complete.[2/26/2007 4:07:12 PM]: Verbose: Starting object: Web Application.[2/26/2007 4:07:13 PM]: Progress: [Web Application] 50 percent complete.[2/26/2007 4:07:13 PM]: Verbose: Starting object: SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9.[2/26/2007 4:07:13 PM]: Verbose: [SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9] SQL Server Connection String: Data Source=poweredge1850;Initial Catalog=SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9;Integrated Security=True;Enlist=False;Connect Timeout=15.[2/26/2007 4:07:13 PM]: Verbose: [SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9] SQL command started at: 2/26/2007 4:07:13 PM. This command may take a while to complete and without notification.[2/26/2007 4:07:13 PM]: Verbose: [SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9] SQL Server Command: BACKUP DATABASE [SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9] TO DISK=@db_loc WITH NAME=@db_name, STATS=5, NOINIT, NOSKIP, NOFORMAT, NOREWIND @db_name=SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9, @db_loc=Z:\Archive\test\test2\spbr0000\0000000C.bak[2/26/2007 4:07:13 PM]: Error: Object SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9 failed in event OnBackup. For more information, see the error log located in the backup directory. SqlException: Cannot open backup device 'Z:\Archive\test\test2\spbr0000\0000000C.bak'. Device error or device off-line. See the SQL Server error log for more details.BACKUP DATABASE is terminating abnormally.[2/26/2007 4:07:13 PM]: Debug: at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlDataReader.ConsumeMetaData() at System.Data.SqlClient.SqlDataReader.get_MetaData() at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.RunCommand(SPBackupRestoreInformation args, Boolean& restart, SPSqlBackupRestoreConnection connection) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupRestoreHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.Backup.SPSqlBackupHelper.Run(SPBackupRestoreInformation args) at Microsoft.SharePoint.Administration.SPDatabase.OnBackup(Object sender, SPBackupInformation info)[2/26/2007 4:07:13 PM]: Verbose: Starting OnBackupComplete event.[2/26/2007 4:07:13 PM]: Verbose: Starting object: Farm.[2/26/2007 4:07:13 PM]: Progress: [Farm] 100 percent complete.[2/26/2007 4:07:13 PM]: Verbose: Starting object: SharePoint_Config.[2/26/2007 4:07:13 PM]: Verbose: Starting object: Windows SharePoint Services Web Application.[2/26/2007 4:07:13 PM]: Progress: [Windows SharePoint Services Web Application] 100 percent complete.[2/26/2007 4:07:14 PM]: Verbose: Starting object: SharePoint - 80.[2/26/2007 4:07:14 PM]: Progress: [SharePoint - 80] 100 percent complete.[2/26/2007 4:07:14 PM]: Verbose: Starting object: WSS_Content.[2/26/2007 4:07:14 PM]: Verbose: Starting object: WSS_Administration.[2/26/2007 4:07:14 PM]: Progress: [WSS_Administration] 100 percent complete.[2/26/2007 4:07:14 PM]: Verbose: Starting object: Web Application.[2/26/2007 4:07:14 PM]: Progress: [Web Application] 100 percent complete.[2/26/2007 4:07:15 PM]: Verbose: Starting object: SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9.[2/26/2007 4:07:15 PM]: Finish Time: 2/26/2007 4:07:15 PM.[2/26/2007 4:07:15 PM]: Progress: Completed with errors, please refer to the log file for details.[2/26/2007 4:07:15 PM]: Verbose: Deleting the file Z:\Archive\test\test2\spbr0000\spbackup.xml and replacing it.[2/26/2007 4:07:15 PM]: Verbose: The backup/restore process included the following objects:[2/26/2007 4:07:15 PM]: Farm\ *[SharePoint_Config]\ Windows SharePoint Services Web Application\ SharePoint - 80\ *WSS_Content\ [WSS_Administration]\ [Web Application]\ *SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9\[2/26/2007 4:07:15 PM]: Completed with 0 warnings.[2/26/2007 4:07:15 PM]: Completed with 3 errors.[2/26/2007 4:07:15 PM]: Error: Backup failed for Object SharePoint_AdminContent_6f2cb892-5330-4748-adb5-075cb5161aa9 failed in event OnBackup. For more information, see the error log located in the backup directory.[2/26/2007 4:07:15 PM]: -------------------------------------------------So my questions are:What is going wrong with the backup that is causing the SQL errors.How to I backup to the original location without having to remove all of the spaces in the directory names?
February 27th, 2007 12:12am
One thing that I found is that you must backup to a shared folder, not a local drive. What I did was to take my local drive and share out the folder I wanted to backup into.
Free Windows Admin Tool Kit Click here and download it now
February 27th, 2007 3:08pm
On the sql side, your identity at log in (when you run the script) will be passed to the DB. If that identity doesn't have access you'll get the exepect ed error. If this is can be thrown in a.bat and scheduled, make sure the run-as has perms at the sharepoint level as well as with SQL
March 28th, 2007 7:01pm
Couple of points
Backup to a UNC path and make sure you as the person executing the command has farm admin and sql admin righs. Also make sure that the service account used for SQL has permissions to the folder you are backing up to.
Free Windows Admin Tool Kit Click here and download it now
September 11th, 2007 6:23pm
HiI wanted to thank Neil for pointing me in right direction. My problems "
Object SharedServices1_Search_DB failed in event OnBackup" and similar error messages started when I moved my backup location from Sharepoint server to UNC network location. I tried many things but - I even tried to login with Sharepoint service account and do the backup but it didn't work - even though this same account "spservice" had "Full control" on this network share folder. So, what eventually did help me was to (for testing purposes only) change NTFS permissions on network share where my backup was done. I gave Everyone and Anonymous group "Full control" permissions on my \\fileserver\StsadmBackup folder. After I did that - backup was done succesfully! :)Anyway, at least now I know that everything is OK with my Sharepoint frontend and DB servers. It was permissions that was the issue. I will probably move backup folder back on frontend machine or I will leave UNC path on network share but really need to get rid of anonymous and everyone groups.Hope this helps.Regards,Damir.DI
January 17th, 2010 5:48pm
hi
Grant all your MOSS and SQL service accounts with full permission on your shared folder.
Tested and working fine for me.
regards
hanees
Free Windows Admin Tool Kit Click here and download it now
January 16th, 2011 5:47am