Unable to restore Site Collection

Sometimes when trying to restore a content database to a SharePoint site you will get the following error:

The site collection could not be restored. If this problem persists, please make sure the content databases are available and have sufficient free space.

Backing up content databases through STSADM commands can be easy and quite useful, but sometimes you will get errors such as the above.

These are the STSADM commands for backups and restores that I'm talking about:

stsadm -o backup -url <URL name> -filename <file name> [-nositelock] [-overwrite]

stsadm -o restore -url <URL name> -filename <file name> [-hostheaderwebapplicationurl]<Web application URL> [-overwrite]

I've recently come across this error when migrating a SharePoint site to a new server. There can be several causes for it.

Lack of disk or database space

The most obvious solution is to check if there is enough disk space. This solution is addressed in KB 926061.

An amount of free space equal to the size of the backup file is not enough. There needs to be enough room for temporary files, transaction logs, virtual memory and other types of files. Be sure to have free space in the order of 1.25 up to 2 times the size of the backup file.

It's also important to make sure that the database growth is not being restricted in SQL server.

IIS locking the site

This also appears to be a frequent cause of this error message. In this case the solution is easy:

  • Stop IIS, using iisreset /stop
  • Perform the restore operation
  • Start IIS again, using iisreset /start or just iisreset

Database orphans

Having orphans in a SharePoint content database can also cause this error message. Orphans are objects with no parent or child relations. They are inconsistencies in the database caused by different reasons, e.g. failed upgrades.

The database can be repared using the databaserepair STSADM command:

stsadm -o databaserepair -url <url name> -databasename <database name> [-deletecorruption]

After doing the repair, try the restore command again.

Locked Site Collections

Sometimes a Site Collection is locked and remains in that state, either because of a failed operation or because someone forgot to remove the lock.

You can check if a Site Collection is locked with the getsitelock STSADM command:

stsadm -o getsitelock -url <URL name>

The lock can be changed using the setsitelock command:

stsadm -o setsitelock -url <URL name> -lock {none | noadditions | readonly | noaccess}

Conclusions

I'm sure there can even be more reasons for this error. The message itself should be much more informative about the type of problem.

As a last resort you can try adding a new content database to the SharePoint application.