feat(ENG-758673): add DbRestoreOverwritePolicy to Restore-CohesityMSSQLObject - #262
Merged
Conversation
deepayan-bose-cohesity
requested review from
deepak-patel-cohesity and
kavinagrawalcohesity
August 27, 2026 07:26
…QLObject Expose overwrite-existing-database support on the local MSSQL restore cmdlet for parity with Restore-CohesityRemoteMSSQLObject (RFPE-2273 / Rijkswaterstaat). When -DbRestoreOverwritePolicy is specified, the cmdlet sets sqlRestoreParameters.overwritePolicy to kOverwrite on the existing ApplicationsRestoreTaskRequest payload sent to POST /public/restore/applicationsRecover. No model or API changes required; SqlRestoreParameters.OverwritePolicy was already defined but unused. Backward compatible: default behavior unchanged (fail if DB exists). Co-authored-by: Cursor <cursoragent@cursor.com>
deepayan-bose-cohesity
force-pushed
the
ENG-758673
branch
from
September 2, 2026 06:10
885101b to
e3cd1c8
Compare
Contributor
Author
Amendment (post-review update)The implementation was refined after initial review: Before: After: applicationRestoreObject.SqlRestoreParameters.OverwritePolicy = DbRestoreOverwritePolicy.IsPresent
? Model.SqlRestoreParameters.OverwritePolicyEnum.KOverwrite
: Model.SqlRestoreParameters.OverwritePolicyEnum.KFailIfExists;
Cmdlet help text was also updated to document that the default is Behavior impact: Restore semantics are unchanged — fail-if-exists without the switch, overwrite with it. The difference is that the default policy is now explicitly sent in the JSON payload rather than relying on Iris server-side defaults. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
-DbRestoreOverwritePolicyswitch parameter toRestore-CohesityMSSQLObject, bringing it to parity withRestore-CohesityRemoteMSSQLObject.The cmdlet now always sets
sqlRestoreParameters.overwritePolicyon thePOST /public/restore/applicationsRecoverrequest:overwritePolicysent-DbRestoreOverwritePolicyspecifiedkOverwritekFailIfExistsBackground
Restore-CohesityRemoteMSSQLObjectalready exposes-DbRestoreOverwritePolicyfor inactive-job restores via the legacy Iris API. The localRestore-CohesityMSSQLObjectcmdlet (C# implementation using the public restore API) had no equivalent option, so users could not request overwrite behavior when restoring SQL objects through the standard cmdlet.The
SqlRestoreParametersmodel already includes anoverwritePolicyfield withkOverwriteandkFailIfExistsenum values — no model or API contract changes were required.Changes
RestoreCohesityMSSQLObject.cs-DbRestoreOverwritePolicyswitch parameter with cmdlet help textSqlRestoreParameters.OverwritePolicybefore submitting the restore task:KOverwritewhen the switch is presentKFailIfExistswhen the switch is omitted (explicit default, documented in help text)Backward compatibility
Restore semantics are unchanged: without the switch, restore continues to fail if the database already exists at the target. The amendment makes this explicit in the request payload by always sending
overwritePolicy(kFailIfExistsby default) rather than omitting the field.Test plan
-DbRestoreOverwritePolicy— verify fail-if-exists behavior; confirm request payload contains"overwritePolicy": "kFailIfExists"-DbRestoreOverwritePolicy— verify restore succeeds and overwrites the existing database; confirm payload contains"overwritePolicy": "kOverwrite"Restore-CohesityRemoteMSSQLObject -DbRestoreOverwritePolicyto confirm both setoverwritePolicy: kOverwritewhen overwrite is requestedGet-Help Restore-CohesityMSSQLObject -Parameter DbRestoreOverwritePolicyto verify help text documents thekFailIfExistsdefaultRelated