Skip to content

Instantly share code, notes, and snippets.

@Andrey2G
Last active January 25, 2019 14:40
Show Gist options
  • Save Andrey2G/b2c3704f3dab02709375bd1f1c55915b to your computer and use it in GitHub Desktop.
Save Andrey2G/b2c3704f3dab02709375bd1f1c55915b to your computer and use it in GitHub Desktop.
restoring TFS Database on the other server without ldf files
USE master
GO
CREATE DATABASE Tfs_DefaultCollection
GO
ALTER DATABASE Tfs_DefaultCollection SET OFFLINE
GO
-- NOW Delete Tfs_DefaultCollection mdf and ldf files
-- AND copy mdf you need to restore
ALTER DATABASE Tfs_DefaultCollection SET ONLINE
GO
ALTER DATABASE Tfs_DefaultCollection REBUILD LOG ON
(
NAME='Tfs_DefaultCollection_log',
FILENAME='c:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\Tfs_DefaultCollection_log.ldf'
)
GO
ALTER DATABASE [Tfs_DefaultCollection] SET MULTI_USER
GO
-- Do the same for Tfs_Configuration and Tfs_YourCollection files
@Andrey2G
Copy link
Author

Server is died, and TFS files has been copied from Raid.
ldf files was corrupted
This script allow to restore TFS Databases on new server
Сonclusion: Do backups every day!
Note:
You also need to modify web.config->appSettings->applicationId with a value from field HostId from the table Tfs_Configuration.tbl_ServiceHost
where name=TEAM_FOUNDATION
Also, please check Tfs_Configuration database Extended Properties->TFS_SERVICE_LEVEL should be the same as web.config->appSettings->staticContentVersion
web.config from "Path to TFS"/Application Tier/Web Services/web.config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment