New command: New-DbaDatabaseMirror #675

Open
ctrlbold opened this Issue Feb 8, 2017 · 9 comments

Projects

None yet

4 participants

@ctrlbold
Member
ctrlbold commented Feb 8, 2017

Is this a feature OR bug:

Feature

New command

Hey @FriedrichWeinmann, would you be able to take this one along with any other internal/external commands it would produce?

If so, would it be done by our feature freeze date of March 1?

Steps to setup mirroring

  • Set All Databases being mirrored to Full Recovery if not already.
  • Copy-SqlDatabase -Source SourceSQL -Destination DestSQL -AllDatabases -BackupRestore -NetworkShare \nas\folder\ -NoRecovery
  • Set CopyOnly To False if there is no valid TLog chain. (Requires: #674 for copyonly)
  • Backup and Restore A Tlog (or any TLogs since full backup) (Stuart's #495 will hellla help)
  • Configure EndPoints on Principal and Mirror Servers. Witness support?
  • Start Mirroring (Async or Sync)
@Stuart-Moore
Contributor
Stuart-Moore commented Feb 8, 2017 edited

Had started work on this, but as it relied on the restore stuff being in I've not gotten much further than this - https://gist.github.com/Stuart-Moore/19e730d58e4c91d8ef753663ac8488fb

Should call itself recursively if any log backups happen while it's restoring stuff.

If it's of use happy to push the branch up.

@ctrlbold
Member
ctrlbold commented Feb 8, 2017

Look at that! totally is, @Stuart-Moore

@ctrlbold
Member
ctrlbold commented Feb 8, 2017 edited

This MSDN page has a lot of bad, but can be gutted for parts, perhaps.

@FriedrichWeinmann
Contributor

I'll have look into it first, before I can commit to being able to do it in the timeframe. Will have more info tonight, possible tomorrow morning.

@wsmelton
Member
wsmelton commented Feb 8, 2017 edited

Question: Why would we call this New-DbaDatabaseMirror when technically mirroring is on the depreciation list with Microsoft? Why not use this for setting up an Availability Group?

Or if we are going to keep it at the current name, what will we call the one for preparing a replica and the databases to setup an AG?

@wsmelton wsmelton added the enhancement label Feb 8, 2017
@ctrlbold
Member
ctrlbold commented Feb 8, 2017

The AGs can be built on top of/in conjunction with New-DbaDatabaseMirror. I believe it's Log Shipping that's deprecated (but that's still on my todo list because people still use it specifically for migrations since it's not edition dependent like mirroring.)

That reminds me, I believe that Mirrors require the same editions so we'll need to ensure they match/do further research.

I actually suck with AGs and don't know the steps and thus the words. But in looking at Microsoft's module, it looks like we can do more of the work for ppl (I dont want to support stuff to their granularity -- I'd rather us be the wizard)

@Stuart-Moore
Contributor
@wsmelton
Member
wsmelton commented Feb 8, 2017 edited

OH NO, log shipping ain't going anywhere. Mirroring was added to the list with SQL Server 2012. Log shipping will be around forever, only way you can do DR in some situations.

With regards to version they do not have to be the same. You can have a principal be at 2008 R2 and the mirror at 2012...this is common practice for doing online migrations. The thing you do need to check is the Edition, for it to be supported by Microsoft they have to be on the same Edition. Reference

I have used code with SQLPS or SMO to build out an AG, already have it scripted for work actually when I do builds for clients. I know Thomas Stringer posted how to do it with SMO on Scripting Guy Blog...which that is one big a$$ picture of him on that post :) I'm working on taking his code to improve what I have written for work.

@wsmelton wsmelton added New Command and removed enhancement labels Feb 8, 2017
@FriedrichWeinmann
Contributor

Alright, as promissed, I checked:
I should be able to do this within the limit with a safe margin.

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