Backup for Files - How do I backup SharePoint?

Written By Tami Sutcliffe (Super Administrator)

Updated at March 31st, 2021

Overview 

Microsoft SharePoint stores its information in several types of Microsoft SQL Server databases: configuration database, content databases, databases for Shared Services Providers (SSPs), search databases for SSPs, and search databases. Backing up SharePoint is as simple as backing up the SQL databases that contain the SharePoint data. Performing a backup at the SQL level allows you to capture a consistent snapshot of all SharePoint data, including a consistent snapshot of the configuration database and Central Administration content database. 

Alternatively, you can choose to backup only certain content databases or backup at the collection level by using the stsadm tool (only for collections smaller than 15 GB). Note that if you backup using this technique, you will need to manually recreate the configuration database if the entire server crashes (unless you also have SQL-level backups). Instructions for doing this are described here. This is also useful if you need to perform a SQL-level restore to a SharePoint server that has a different configuration than the original server where the configuration database was backed up.

Instructions for SQL-level backups

This strategy directly backs up the SQL server databases. This tends to be the most efficient method to backup SharePoint databases (especially for databases larger than 30 GB). The disadvantage is that when you restore the information you can only restore at the database level--finer granularity is not possible without first recovering to a SharePoint recovery farm. We recommend using this technique for your remote and local backups, and possibly combining this strategy with some of the other strategies as needed. 

  1. In the backup manager, go to the Folders page.
  2. Use the Add button to add all of the folders containing the data and transaction log files for all of your SharePoint databases (usually [and by default], these files have the .MDF, .LDF, and .NDF file extensions, but not always; refer to the database information in the SQL Server Management Studio if there is any question). Save changes to close the dialog.
  3. On the Folders page, for each folder that contains SQL data, right click the folder and choose Properties. Change the Always Check Block Fingerprints option to be set to Yes.
  4. Optionally, you can backup the search indexes. If you don't backup the search indexes, then after restoring you will have to perform a full recrawl to rebuild the search index. The search index is stored both in the search index SQL databases (which you can select in step 2 above) and then also the search index file(s). Both must be backed up if you want to be able to restore search indexes. To determine the location of the search index files, open a command prompt and run:

    stsadm -o spsearch -action list

    It will print out information about each farm. Look for a line that starts with "Index location:" -- this line of text indicates the directory where the search indexes are stored. Once you know the directories that contain these search indexes, open the backup manager, go to the Folders page, click Add, and add the appropriate directories containing the indexes to the backup set.

See also our KB article on how to backup SQL server databases for further clarification.

Instructions for SQL-level backups using SQL Server backup tools

This strategy uses the backup tools built in to SQL Server to generate backup files of the appropriate SharePoint SQL databases. You then add the locations containing these SQL backup files to the Folders page in the backup manager, and finally customize the versioning settings so that only 14 to 31 days of versions are retained. This technique is only recommended if your databases are less than 15GB in total size, as the process tends to be less efficient than direct SQL Server backups (see previous section).

  1. Decide on a local folder, network share, or NAS device that can contain the local SQL backup files. The location should have enough disk space to contain several copies of the SQL database.
  2. Follow these instructions in Microsoft TechNet to use the SQL Server Management Studio to schedule backups of the configuration database, content databases, SSP databases, search databases, and search databases for SSPs. You should choose to perform a full backup every day and to store the backup to a different filename based on the date. (If you want to use a combination of full and differential SQL backups, then you will need to skip step 4 below.) Make sure that you store the resulting backup files in the location you chose in step 1.
  3. Go to the Folders page in the Backup manager. Click the Add button and add the location you chose in step 1. Save changes to close the dialog.
  4. Right click the folder just added to the Folders page and choose Edit Policy. Add a new wildcard rule similar to the following:

    Exclude files whose relative pathname matches the following: *.*

    Also check the box in the rule editor that says 'Older than N days' and choose N to be something between 10 and 31. You should also check the 'destroy files excluded by this rule' option in the rule editor. This policy rule ensures that older full backup images will automatically be purged from the backup.

Instructions for granular backups with stsadm tool

You can use the stsadm tool that comes with SharePoint to perform backups of individual content databases or collections. Backups with stsadm tend to be less efficient, but provide greater granularity during the restore. The general process is to create a .bat file that executes stsadm (one or more times) before the backup begins, which generates a set of backup files in either a local directory or a network share or NAS device. You then add these locations to the Folders page in the backup manager to ensure they are backed up remotely.

  1. Decide on a local folder, network share, or NAS device that can contain the backup files generated by stsadm. The location should have enough disk space to contain several copies of the SharePoint database.
  2. Open notepad and create a .bat file that calls stsadm to perform a full unattended backup of either the entire SharePoint system, specific content databases, or specific site collections. The instructions on how to create such a .bat file can be found in this TechNet article. Note that the section on scheduling a backup in this article is not relevant here. Below are some example .bat files, which assume that your backup location chosen in step 1 is E:\SharePointBackups:

    .BAT file to backup entire farm:

    cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN
    stsadm.exe -o backup -directory "E:\SharePointBackups" -backupmethod full -overwrite

    .BAT file to backup content databases:

    cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN
    stsadm.exe -o backup -directory "E:\SharePointBackups" -backupmethod full -overwrite -item databasename
        (repeat this for each database you want to backup)

    .BAT file to backup site collections:

    cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN
    stsadm.exe -o setsitelock -url url_of_sitecollection -lock readonly
    stsadm.exe -o backup -filename "E:\SharePointBackups\filename_for_sitecollection" -overwrite -url url_of_sitecollection 
    stsadm.exe -o setsitelock -url url_of_sitecollection -lock none
        (repeat these three commands for each site collection to backup; be sure to use a different filename for each collection)

    NOTE: If your site collection is normally readonly, then remove the setsitelock commands. If your site collection normally has a different lock setting other than none than change the -lock argument of the setsitelock command after the backup command executes. See also documentation on the setsitelock stsadm operation.

    .BAT file to backup web applications:

    cd %COMMONPROGRAMFILES%\Microsoft Shared\web server extensions\12\BIN
    stsadm.exe -o backup -directory "E:\SharePointBackups" -backupmethod full -overwrite -item web_application_name
        (repeat this for each database you want to backup)

  3. In the backup manager, go to the Folders page, and use the Add button to add the location you chose in step 1.
  4. Go to the Options page, Backup tab. In the Scripted Actions settings section, add the full path to the batch file you created in step 2 to the Preinit Stop Scripts option. If you created multiple .BAT files, then separate multiple .BAT filenames with semicolons.

Tip: When creating the .BAT file in step 2 above if you need to list all of the available backup items, open a command prompt, and execute the following command to list available items: stsadm -o backup -showtree   (note: items in square brackets cannot be individually selected, but are backed up when their parent item is selected).

External Resources

  1. TechNet: Prepare to backup and restore a farm.
  2. TechNet: Back up a farm by using SQL Server tools.
  3. TechNet: Back up a farm by using built-in tools.
  4. TechNet: Back up a farm by using the stsadm command-line tool.
  5. TechNet: Backing up with the stsadm tool.
  6. TechNet: Back up and restore Web applications.
  7. TechNet: Back up and restore site collections.
  8. TechNet: Back up and restore SharePoint databases.
  9. TechNet: Back up and restore SSPs.
  10. TechNet: Back up and restore SSO.
  11. TechNet: Back up and restore My Sites.
  12. TechNet: Back up and recover site objects.