Azure DevOps migration using same SQL Server - tfs

I currently have a TFS 2018 server installation using SQL Server 2017. I'd like to install Azure Devops on a new server but use the same SQL Server.
My plan was to restore the existing Tfs_Configureation and Tfs_Collecton databases as new databases and use them.
However in the installation wizard, I am allowed to pick the configuration database that is to be used but I suspect the collection database will be the current live one.
Is there a support way of altering the collection database inside of the configuration database?
I've found a table called tbl_Database that holds the name and connection strings but am not sure if changing these is enough.
I've found a table called tbl_Database that holds the name and connection strings but am not sure if changing these is enough. I don't want to end up prematurely upgrading the current live collection.
I don't want to end up prematurely upgrading the current live collection and don't want to set up a temporary SQL instance just to test the migration.

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.

Is it possible to restore a TFS collection (db backup only) when no detach was performed?

Trying to attach the database (DefaultCollection), I get prompted with TF254078: No attachable databases were found on the following instance of SQL Server.
The database is restored and running, but I've copied it from another server running TFS.
It seems that to attach a collection, you would have to do a 'detach' before creating a db backup.
Is it possible to attach a collection to TFS with my current db?
The TFS version is 2012
I don't believe you can attach an un-detached collection (although someone may correct me on that). There used to be a tfsconfig.exe recover in 2010 but it wasn't a happy experience and they got rid of it in 2012.
Assuming you have a full backup of the old server (let's call it Server A) and also assuming there are other collections on the new server (let's call that one server B) that you need to retain then you'll have to restore server A, detach the collection and the attach it to the server B.

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

Backing up documents of TFS server

I have been given a task of Backing up of documents in TFS server. I am not sure how to proceed with this. Google search didnot return anything usable.
How can i do this. Please share your experiences.
The Sharepoint library used by Team Explorer's "documents" folder is stored in the two STS_* databases on the SQL server.
Note that partial backups/restores are not supported in TFS 2005/2008. Restoring just the Sharepoint databases without the other ones (especially the TfsIntegration database) would leave you in an inconsistent state. As of TFS 2010 you can do backups/restores at the collection level.
Not exactly sure what documents you are referring to, since TFS follows 3-tier model, will backing up databases that hold your desired data solve your problem?
In my case Documents in TFS were stored in sharepoint site that gets installed when we install TFS. WSS_Content is the name of the database that holds all documents and their version history.
In my case this database was not a part of the maintenance plan in sql server.
So, I modified the maintenance plan and now this database is getting backed up along with other databases.

Resources