In our organization, we work on Visual Studio to manage our SQL Server 2016 databases (with Git on DevOps).
When we push our modifications, the Pipeline takes 1 hour to complete the Release in DevOps because it rebuilds the indexes.
How can we disable the rebuilding of the indexes when we push a modification please ?
The exact message in DevOps log is "... Aletring Index [dbo].....".
Thanks.
Related
I am attempting to refresh a TFS 2015 test environment on a regular basis. The TFS production environment consists out of 3 servers, and the test environment has the exact same layout (separate App, Build and SQL server - no sharepoint involved).
TFS version : 14.0.23128.0 (Tfs2015)
SQL Server 2012 SP2 CU-1
OS : Windows 2008 R2 Enterprise
Seeing that the refresh will occur regularly and to minimize down time, I want to automate / script the process to be execute at night.
Getting a production back-up from the SQL Server seems no problem, as this could be scheduled from within the TFS Admin Console (Scheduled backups).
At this stage I am trying to figure out how the “scheduled restore” will work. In no time I was bumping my head against attempting to stop all collections before the restore starts on the test environment...
My question: Is such an automated style of TFS backup and restore doable, and is there by any chance a product out there that supports this out of the box?
You can setup automated refresh for every MSSQL database. I would do it using SQLAgent task. Restore command should be preceded with following statement to ensure all connections are terminated otherwise restore will fail:
ALTER DATABASE TFS_POC
SET RESTRICTED_USER
WITH ROLLBACK IMMEDIATE
GO
There is not a way to have a total automated style of TFS restore, no matter you are using TFSBackup.exe, or using Restore Databases in Scheduled Backups, selecting your database backup is required. Also, stopping services is necessary, as stopping services helps protect against data loss or corruption during the restoration process.
To provide a bit of feedback on the issue.
The requirements were fairly simple in our case in the sense that we only wanted the version control databases restored.
This simplified things a bit as restoring functionality such as reporting, builds, sharepoint etc. were left out of scope.
In the end I did succeed in getting the process automated to an extent, by making use of an amalgamation of SQL server stored procedures, Powershell and some standard Tfs commands.
The first step was to get the production Tfs databases backed up.
This was achieved by making use of SQL server stored procures.
Note: You must back up all of the databases to the same time stamp to help ensure against data loss!
https://www.visualstudio.com/en-us/docs/setup-admin/tfs/admin/backup/backup-db-architecture
These database backups are then copied to a shared restore location where the test environment’s Tfs SQL Server can access them during the restore process.
This was also done via some SQL stored procedures.
These steps are scheduled within SQL Server to execute nightly, with the previous day’s backup in the shared location being overwritten each time.
For the orchestration of the restore actions involved, TeamCity was used.
When a restore is requested you can initiate (or schedule) it via TeamCity.
The first step will be to stop all the test environment’s Tfs collections.
This was done by using the TfsServiceControl.exe - https://www.visualstudio.com/en-us/docs/setup-admin/tfs/command-line/tfsservicecontrol-cmd
Next we will execute some stored procedures on the test environment’s SQL Server that will start the DB restore process of the test environment’s Tfs DB’s.
The next steps will prepare the Tfs databases to run in the test environment and among other things, clear away the production values that are embedded in them.
This was done by a PowerShell script that in essence just calls the commands that will be run when a manual restore is done. Most of the commands reside within the TfsConfig command.
https://www.visualstudio.com/en-us/docs/setup-admin/tfs/commandline/tfsconfig-cmd
TfsConfig PrepareClone
TfsConfig ChangeServerID
TfsConfig RemapDBs
TfsConfig Accounts /ResetOwner
TfsConfig Accounts /add
TfsConfig registerDB
TfsConfig ConfigureMail
TfsConfig RebuildWarehouse
Clearing cache
After these steps were completed the test environment’s Tfs collections are started.
This is done by using the TfsServiceControl.exe - https://www.visualstudio.com/en-us/docs/setup-admin/tfs/command-line/tfsservicecontrol-cmd
It is now possible to request or schedule a restore. A bit primitive, but so far it works fine.
I have one production database and a test database. Now and then I delete the test database, and make a fresh duplicate from the production db.
I am pretty scared that at a brainless moment I will by accident delete the production database.
I know that you can restore a deleted database, but even the downtime can be quite catastrophic at certain moments in time.
Is it possible to give it an extra lock or some other way to prevent me from deleting this database by accident?
Don't use an error prone point-and-click interface but instead write a script to delete the test database. You can use either:
Azure Powershell
Azure Cross-Platform CLI
You'll be absolutely safe because you won't have a script to delete the production database !
Dirk - you don't say if this is SQL Server on a VM or an Azure SQL Databsae.
If you are using Azure SQL Database and are using one of the new tiers (Basic, Standard or Premium) you can recover deleted databases back to the point at which they were deleted. The duration these deleted databases are held for depends on tier (7 days Basic, 14 days Standard, 35 days Premium). Full details on the Azure documentation website.
I need to be able to script the following process and would be grateful for any guidance in achieving it!
We have a live database which is backed up every night (SQL 2008 R2). We have a 3rd party which requires access to the database but management have decided they can have access to a time-delayed copy instead. So I have been tasked with restoring the previous nights backup to another SQL instance, complete with login information to which the 3rd party can access without impacting the live database.
I believe a script could perform the task, except the backup file name is not constant (i.e databasename_2015_02_15_223005_3661110) and I can't figure out a way of automating a restore without knowing the backup name. We keep 3 days of full backups on the server before they are archived.
Instead should I be looking at either snapshots or replication to produce the 24 hour delayed copy?
I have a server which is running SQL Server 2008R2 SP1 and there are more than 200 online databases with their specific login and I want to move all of these databases to another machine with the same software SQL Server 2008R2 SP1.
I can afford downtime up to 8 hours so I'm not looking for complex solution like database mirroring and logshipping.
I have tried Backup & Restore, it work fine but trouble me in two ways :
1- I couldn't transfer login to new server so all of my users will have to create their user again which will my users to get angry.
(I have tried to script all of the logins from the security section but since I have realize the hash algorithm between two system maybe different, I cannot transfer my logins in this way)
2 - I have to backup & restore each database one by one which is so time consuming.
I have also tried copy wizard, but I have encountered with following error message at the final stage :
"SQL Server schedule job" job failed the job was invoked by user sa step to run was step 1.
Since mysource server is running based on windows server 2003, I cannot use the powershell V3 solution.
I have done many searches but all I found was a solution to transfer one database to another server.
But since I'm looking for a solution to transfer mass databases, this situation is being hair pulling and so difficult So I wil be very appreciated if you can provide me an easy and practical solution.
for moving logins between servers
https://support.microsoft.com/en-us/kb/918992
[moving logins][1]
then backup and restore all databases in that migraton day using pre built restore script if the db size is small , later restore the differential backups and make it online. if the size is an issue then implement log shipping or mirroring
I need some help for executing my planned backup strategy.
My database is about 1 gig in size.
I want to perform a full backup once per week, and incremental every hour.
Is all of this built into SQL Server 2005 Express?
Is it possible to roll over the backups so I only keep 1 months of backups?
Meaning the full weekly backup has 1 for each week, on the 5th week it writes over the oldest full backup.
You can do it, it's just harder.
You don't have maintenence plans, but that doesn't matter becuase they often cause more headaches than they solve. You will want to script the backup yourself.
The other issue is you won't have the SQL Server Agent, which is used for scheduling your scripts. You can solve this by using sqlcmd and the windows scheduler.
SQL Server express does not have the ability to setup maintenance plans, therefore you must manually execute the scripts. AFAIK.
With all other editions, a simple DB Maint. plan can be setup to do all of this, and it will even walk you through the process.