There are times that you need to restore a database backup to a different database name. You may need it for testing or data migration. In my case, I needed to rename a TFS 2013 project collection and one of the steps is to backup and restore the TFS project collection to a new database name.
Here are the steps on how to do it:
1. Open up your SQL Server Management Studio and connect your SQL Server instance to back-up the project collection database. Look for the project collection database. Normally named as “Tfs_Collection Name”. Right click the database and select properties. From the properties page, choose “Options” and go to “State” and restrict access to “Single_User”.
2. Click “Yes” to ensure all connections are closed.
3. Right click the project collection database again and create a backup.
4. Verify your backup location.
5. Take the database offline and then detach.
6. Restore the database to the a new database name.
7. Locate your backup file.
8. Make sure to change the database name to the new name.
9. Change the filenames to match the new database name.
You are done!