How to move a SharePoint Content Database to a new physical drive/location

There may come a time when you want to move a SharePoint content database from one disk on your SQL Server to another. Perhaps you installed SharePoint in standalone mode and don’t like the location it chose or you just need to move some stuff around. The following assumes you are moving the database from one disk to another on the same SQL Server and that you don’t need to let SharePoint know what is going on (this is happening ‘under the hood’).

 

Steps

  • You can never have enough backups, take one, just for good measure
  • Prune transaction logs, to keep the files (*.ldb) necessary to move, smaller
  • Stop services that depend on the database (SharePoint, IIS/Web)
  • Detach the database(s)
  • Move the database(s) and their logfiles
  • Attach the database(s)
  • Bring the services back online
  • Test/validate all is well

   

   

Stop All SharePoint Related Services

   

   

   

  • IIS Admin Service (and likely SMTP as a dependency)
  • All SharePoint Services
  • World Wide Web Publishing Service

 

   

Detach the Database(s) you intend to move

   

   

 

   

Move the Databases and their Logfiles

   

   

   

Figure 1: This step takes as long as it takes… plan accordingly for size vs time

 

   

Reattach the Databases

   

   

 

   

 

   

   

   

Restart all Stopped Services

   

Start the services you stopped earlier

 

   

Test

   

Make sure it works, eh? Check logs, etc.

 

 

That’s it. Easy Peasy.