Restore tfs collection from mdf/ldf - tfs

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!

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".

Team Foundation Server 2017 - Database Restore failing

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.

Change credentials per server?

I've installed opshub on my pc that is on domain ABC. I have succesfully migrated projects from a TFS server on domain ABC to visual studio online. Now I've added a TFS server that is in domain DEF and it doesn't ask me for credentials for that server. I just get a blank collection list, I think its trying to use my current credentials from domain ABC. How can I get it to ask me for the credentials to domain DEF when trying to access that server?
User level authentication details are stored inside Team Foundation cache directory under following locations. If you have already authenticated for the TFS server then details for that server is stored inside cache directory. This won't ask you credentials again while you are doing next migration.
If you want to authenticate with the new credentials for different domain you need to clear data from the following directories.
C:\Users{User}\AppData\Local\Microsoft\Team Foundation\4.0\Cache
C:\Users{User}\AppData\Local\Microsoft\Team Foundation\5.0\Cache
Make sure original folders remains there (Cache). Just remove contents of those directories. Also make sure you close all the applications which uses TFS cache like visual studio, opshub migration utility.
See http://blogs.msdn.com/b/visualstudioalm/archive/2012/08/29/clearing-the-credentials-for-connecting-to-a-team-foundation-server.aspx for correct answer. It worked for me.

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

Source Control Workflow: synching code changes on a staging webserver

I am currently using TFS to source changes to a web site code base. Currently, when I'm done making a change, I need to deploy the changes to a web server for review by the end user.
Generally the way I would do this is just connect to that machine via RDP, open visual studio and get latest to pull changes...
However, this only works if I'm the only one working on the entire site. If someone else RDP in to make changes, the site is locked to my TFS account, and they can't make any changes to it...
They could pull their own copy of the site into their own machine via TFS and check in the changes there but because so much of their part is done on the database (vs code) they'd have to duplicate everything they do into the website every time them commit a change, so they prefer to work directly on the machine...
is there any way to make this work, a better way to set this up so I can pull their changes into my local copy via TFS?
my biggest problem to overcome is the fact that when I Get Latest on the webserver via RDP it locks the entire solution to my TFS account, so that when they login to RDP with their credentials, they can't make any changes because the files are checked in, and of course they can't checkout because of course the solution is tied to my account.
If I can get past that I think we'd be okay.
any info is appreciated, please let me know if I can provide more context, thanks
Can you set up a different TFS workspace for each user on your RDP machine? This should allow multiple users to use the TFS client to pull the same solution on the same machine without issue.

Resources