Skip to content

Added DisableJobsOnDestination flag to Copy-SqlJobServer - #5

Merged
potatoqualitee merged 2 commits into
dataplat:masterfrom
thomasalley:master
Jan 28, 2016
Merged

Added DisableJobsOnDestination flag to Copy-SqlJobServer#5
potatoqualitee merged 2 commits into
dataplat:masterfrom
thomasalley:master

Conversation

@thomasalley

Copy link
Copy Markdown
Contributor

I ran into a scenario where I wanted to copy all of the jobs from server A to server B, but those copied jobs needed to be immediately disabled on server B. Dropped a flag into Copy-SqlJobServer to support this by disabling the job in the SMO object before scripting out for the copy. Figured other people working with Availability Groups may want the same functionality.

I also ran into a situation where job creation on the destination was failing due to the Job's starting database not existing on the server. Since the exception had 'exist' somewhere in there, the command misreported that the job had already been migrated. Tweaked that check and added a Write-Error to get some useful output from this case.

…eady exists, when in fact the job creation failed. Added a Write-Error for the InnerException message in these cases.
potatoqualitee pushed a commit that referenced this pull request Jan 28, 2016
Added DisableJobsOnDestination flag to Copy-SqlJobServer
@potatoqualitee
potatoqualitee merged commit d5fe6c3 into dataplat:master Jan 28, 2016
@potatoqualitee

Copy link
Copy Markdown
Member

Awesome, thanks, Thomas!

potatoqualitee pushed a commit that referenced this pull request Aug 9, 2016
Syncing Development 2016-08-08
dansqldba pushed a commit that referenced this pull request Oct 13, 2016
Refresh Dev branch - 2016-09-05
potatoqualitee pushed a commit that referenced this pull request Jun 30, 2017
potatoqualitee pushed a commit that referenced this pull request Jul 12, 2018
potatoqualitee pushed a commit that referenced this pull request Jul 21, 2026
Invoke-DbaDbMirroring creates a "Mirroring" database-mirroring endpoint on BOTH
instances to establish the session. Both suites tore down the mirrors and the
databases but never the endpoints, so every run left them behind on the Multi
pair. specs/lab-requirements.md requires those instances to be endpoint-free and
LAB-12 enforces it, so preflight failed chronically - and a check that is always
red is a check everyone learns to ignore, which is how the LAB-02 constants drift
survived 14 days (#5).

Measured: both sqldev and sqlcluster carried a leaked "Mirroring" endpoint with 0
mirrored databases in use. Dropped them; they came back on the next mirror run,
which is what made this issue #16 rather than one-off cruft.

Adds endpoint teardown as the third cleanup step, following the pattern
Copy-DbaEndpoint.Tests.ps1:60-61 already uses. In Get-DbaDbMirrorMonitor it goes
in the existing finally so it survives a throwing mirror teardown.

Swept all three suites that call Invoke-DbaDbMirroring; Invoke-DbaDbMirroring's
own suite already removed its endpoints (on the Copy pair).

NOT yet verified end to end: #16 asks that LAB-12 be green AFTER the suites run.
Get-DbaDbMirrorMonitor currently hard-kills the PowerShell process mid-suite (#19),
so its AfterAll never executes and the endpoints still leak from that suite. The
teardown here is correct but unreachable until #19 is fixed.

(do Get-DbaDbMirror, Get-DbaDbMirrorMonitor)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants