Team Foundation Server 2017 - Database Restore failing - tfs

I am running through my disaster recovery process for TFS 2017/18 and am trying to restore the databases to the SQL server 2016 instance on the same machine as the TFS Admin tool.
I am using the TFS Administration Tool to take the full backups and also to restore them.
The issue is that after the ReportServer and ReportServerTmp DBs get restored, the TFS_Warehouse and other TFS_ databases hang while doing the restore.
The log file shows the error message: Login Failed for user 'domain\machinename$' Reason: Failed to open the explicitly specified database 'ReportServer'. [CLIENT: ]
The SQL Server has the NT Authority/Network Service account and I have also tried giving it 'domain\machinename$' as well.
I have compared it to another Virtual Machine that has a standard installation of SQL Server and TFS Server on it and I cannot see any obvious difference.
Does anyone know of a solution for this?
Regards

Based on the error message "Login Failed for user 'domain\machinename$' Reason: Failed to open the explicitly specified database 'ReportServer'. [CLIENT: ]".
Seems the related database had been dropped (database missed) or there is any service is trying to access the database which does not exist.
That means you did not restore the databases correctly or you did not really full back up the databases correctly. And when you use SSMS and manually restore each database, the related database online again, so it works.
Yes we recommend use the Scheduled Backups feature wizard to backup or restore the DBs. However you need to note below things:
You can use the backups you made of the original deployment to restore
the data from that deployment to the new server. When restoring the
data, be sure to restore all databases and the SharePoint Farm to the
same point in time. If you followed the guidance in Create a backup
schedule and plan, you used the Scheduled Backups feature to
create your backups. You will use these backups to restore your data.
If you manually configured your backups, you cannot use the Restore
wizard in Scheduled Backups to restore those databases. You must
manually restore them using the software you used to back them up.
Source : Restore the databases
Generally, we can use the SQL Server Profiler to trace the error, then debug accordingly. Within SQL Server Management Studio , choose Tools menu and then SQL Profiler with Audit Login/Logout, User Error Message events selected and check the relative entries of login fails. See below threads for details:
SQL Server Error 18456: Finding the Missing Databases
Login failed for user 'domain\username'. Reason: Failed to open the
explicitly specified database. [CLIENT: ]
UPDATE:
For the account issue, please refer to the Required permissions part in this article :Restore the databases. Just add the TFS service account as the sysadmin role, then try it again.
Required permissions
To perform these procedures, you must be a member of the following
groups or have the following permissions:
A member of the Administrators security group on the server.
Either a member of the SQL Server System Administrator security group, or your SQL Server Perform Back Up and Create Maintenance
Plan permission must be set to Allow.
A member of the sysadmin security group for the databases for Team Foundation.
A member of the Farm Administrators group.

Related

Restoring tfs from backup - problem with attaching collection

I have backups of TFS created by TFS' 2015 scheluded backups and I'm trying to restore them on different server, but for some reason I cannot even attach collection (not even talking about Tfs_Configuration yet). I managed to restore backups via TFS Console -> Scheluded Backups -> Restore
but I cannot attach it
TfsConfig registerDB /sqlInstance:SQL\NEW_TFS /databaseName:Tfs_Collection1
The following exception was caught while trying to validate the database:
TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator.
What's the reason behind this?
I tried this https://stackoverflow.com/a/10853481/10522960 to solve that, but it doesn't help at all
Also
First, please make sure you are a member of the Team Foundation Administrators security group and a member of the sysadmin security group for any SQL Server databases that Team Foundation Server uses.
There's no such group (Computer Management -> Local Users and Groups -> Groups), shouldn't it be created by tfs?
TfsConfig offlineDetach /configurationDB:SQL\NEW_TFS;Tfs_Configuration /collectionDB:SQL\NEW_TFS;Tfs_Collection1
The database 'SQL\NEW_TFS;Tfs_Collection1' is hosting Team Project Collection with ID 'da9b771c-a149-62d1-a7b0-e
1ad79977102', however this collection is not registered in the specified configuration database.
I've been trying to change Application Id inside
C:\Program Files\Microsoft Team Foundation Server 14.0\Application Tier\Web Services\web.CONFIG
to da9b771c-a149-62d1-a7b0-e1ad79977102 but it doesn't help at all
Does anyone has an idea what's going on? Thanks!
If you want to restore the standard backups without detaching a collection you need to restore the configuration database first. You will also need to update the TFS GUID otherwise it will identify as the same TFS server as the original and weird stuff will happen in visual studio.
When you detach a collection all of the collection specific configuration is copied from the configuration database in to the collection database. This process makes the collection portable, note that this will also take the collection offline. You can then back up the collection database and restore it to a new TFS server with a "clean" configuration database. Once the backup is restored you will be able to attach the collection.
Attaching the collection will then copy all of the collection specific configuration in to the new configuration database
Why do you try to use TfsConfig registerDB for collections? According to the manual, RegisterDB moves configuration database only:
Use registerDB to update name of the server that hosts the
configuration database in Azure DevOps Server. You might use this
command when restoring the configuration database to new hardware or
when changing the domain of a deployment.
To attach your restored collection, you can use Team Foundation Server Administration console: Attach the collection
Detach collection using "Team Foundation Server Administration console".
Create backup for detached collection.
Restore backup on destination sql server.
Attache again collection to destination server using "Team Foundation Server Administration console".

TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator

Can someone help me with
how to connect new tfs 2017 update1 to the existing database (MSSQLserver2016) that is in other server. have tried setting this up, but while accessing the tfs application url, it shows as
TF30040: The database is not correctly configured. Contact your Team Foundation Server administrator
If just reinstall TFS on the same machine, then you can point it at the database during configuration. When you reinstall, you should be able to choose the "Application Tier Only" configuration option, which will ask you to point it to the correct databases.
If you want to install a new TFS server using the existing database, after the configuration you can try RemapDBs to redirect TFS to its databases.
I'd recommend backing up the DBs first as a precaution, then Restore an application-tier server or Restore data to a different server than the current one for TFS
Back to the specific error: TF30040: The database is not correctly configured. Contact your Team Foundation Server, it may be caused by many reasons. Here is a similar thread for your reference: TF30040: The database is not correctly configured

How to restore a team foundation 2012 collection?

I was careless not to detach the collection from TFS admin. Now I reinstall Windows, how can I restore the collection back ?
I get the old db restored back on the sql server, but cannot attach it on TFS admin. "No attachable databases were found on the following instance of sql server..."
The current sql server and the old server have different instance name. I try the following command to register the old db(restored already on sql server) back to the tfs collection but it fails for no reason.
TFSConfig RegisterDB /SQLInstance:currentserver /databaseName:Tfs_MyoldDB
show error: The following exception was caught while trying to validate the database:
TF30040: The database is not correctly configured. Contact your Team Foundation
Server administrator.
Thanks.
Do you have the original tfs_config databases? The one where the collection database was attached?
If you do, you can simply uninstall TFS (or use "tfsconfig.exe setup /uninstall:ApplicationTier" from the command line) restore the original tfs_config and collection database and then from the TFS console perform an upgrade or add a new application tier. This will reconfigure using the existing un-detached collection.
This will ask you which DB instance to use and pick up the rest from there.
If databases have not changed in content, but the SQL instance is different you should use the RemapDBs command
TfsConfig.exe remapDBs /databaseName:NEW_SQL_INSTANCE;Tfs_Configuration /sqlInstances:NEW_SQL_INSTANCE

Restore tfs collection from mdf/ldf

My server running TFS express crashed. I managed to mount the disk and extract mdf/ldf file for my TFS collection. Here is what I did next:
Built a new machine (with the same name/IP address) and installed SQL Express/TFS server express.
From SQL Server Management Studio, attached the mdf/ldf files. I can now see TFS_MyCollection as a new database.
From TFS Administrative console, clicked on "Attach Collection."
However, the new database is not being listed.
I went through a bunch of links on the Internet. https://social.msdn.microsoft.com/Forums/en-US/d949edf3-1795-448a-a1cc-39555ce87b50/tfs-2010-installation-error had a similar situation. Based on the suggestion, I had attached the database. I also looked at https://msdn.microsoft.com/en-us/library/ms404869(VS.80).aspx. However, this one talks about using backup/restore, which is not my case.
I must be missing some configuration step. Please advice. Regards.
You cant just attach a collection that was never detached.
You need to unconfigure your TFS instance (tfconfig.exe setup /uninstall:all) and then restore all of the databases.
You will need to restore each collection and the configuration DB. They are currently a set. Once you have all of the databses attached/restored you need to run the setup and "configure application tier only".
https://msdn.microsoft.com/en-us/library/ms404869.aspx
You need to follow the documentation for moving hardware. Make sure that you follow each step.
Note: You should take backups!

TFS 2012 - Scheduled Backups Failing

I'm trying to setup Nightly Backups for my TFS 2012.4 development box going off to another server, but it's failing.
The server is has SQL Express and TFS Express on it, trying to send the backups over to a network path on another share.
When going through the Wizard it will successfully pass all of the Readiness Checks, including permissions. It will fail when it tries to run the backup job for the first time under Confirming Permissions.
Error is:
TF401002: The SQL Server Database Engine failed to save the database
backup to path \[share]\c$\TFSBackup. Please grant SQL service
account read/write access to that folder.
I've tried adding "Everyone" with full control to the folder on the backup server, but it still fails with the same error.
Added the full log to http://pastebin.com/80PrYXqx
This may be a problem with using the administrative share path of c$. I suggest you go to your [share] server and make the TFSBackup folder a shared folder, and give your share the appropriate permissions.
Then you can change this:
\\[share]\c$\TFSBackup
To something like this(depending on what you name your share):
\\[share]\TFSBackup$
I know it's an old post, but just incase anyone else has issues. I had the same issue configuring backups. The following resolved it for me:
1) Open up "Services" and note the "Log On As" user for "Sql Server" and "Sql Server Agent"
2) On the folder that your backups are being saved to, go to Properties -> Security -> Edit
3) Add the users from #1, and check "Full Control", Save

Resources