Skip to content

Restore-DbaDatabase - Add -StopAtLsn parameter for LSN-based restore#10245

Merged
potatoqualitee merged 6 commits into
developmentfrom
claude/issue-10004-20260314-1653
Mar 29, 2026
Merged

Restore-DbaDatabase - Add -StopAtLsn parameter for LSN-based restore#10245
potatoqualitee merged 6 commits into
developmentfrom
claude/issue-10004-20260314-1653

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Fixes #10004

Adds -StopAtLsn parameter to Restore-DbaDatabase and Invoke-DbaAdvancedRestore to support restoring to a specific Log Sequence Number.

SQL Server's STOPATMARK = 'lsn:<value>' syntax is used under the hood via SMO's Restore.StopAtMarkName property. Works with the existing -StopBefore switch to stop just before the LSN.

Generated with Claude Code

Add -StopAtLsn parameter to Restore-DbaDatabase and Invoke-DbaAdvancedRestore
to support restoring to a specific Log Sequence Number using SQL Server's
STOPATMARK = 'lsn:<value>' syntax. Works with -StopBefore to stop just
before the specified LSN.

(do Restore-DbaDatabase)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@andreasjordan

Copy link
Copy Markdown
Collaborator Author

@claude please add the new parameter to the test files.

@claude

claude Bot commented Mar 14, 2026

Copy link
Copy Markdown

Claude finished @andreasjordan's task in 47s —— View job


Adding -StopAtLsn to test files

  • Gather context: find test files and read existing structure
  • Add -StopAtLsn parameter tests to Restore-DbaDatabase tests
  • Add -StopAtLsn parameter tests to Invoke-DbaAdvancedRestore tests
  • Commit and push changes

Added "StopAtLsn" to the parameter validation list in both test files:

  • tests/Restore-DbaDatabase.Tests.ps1 — after "NoXpDirRecurse"
  • tests/Invoke-DbaAdvancedRestore.Tests.ps1 — after "Restart", before "EnableException"
    |

(do *Restore*)

Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
@ReeceGoding

Copy link
Copy Markdown
Contributor

Looks good to me, but I wouldn't trust it without test coverage.

@andreasjordan

Copy link
Copy Markdown
Collaborator Author

I will try to test this in the next days.

@potatoqualitee

Copy link
Copy Markdown
Member

oh la la this is an awesome addition

@andreasjordan

Copy link
Copy Markdown
Collaborator Author

Test works in my lab.

@potatoqualitee

Copy link
Copy Markdown
Member

Hell yeah, DOWN TO LESS THAN 70!!!!!

@potatoqualitee potatoqualitee merged commit 97d03be into development Mar 29, 2026
16 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-10004-20260314-1653 branch March 29, 2026 19:19
@potatoqualitee

Copy link
Copy Markdown
Member

Thank you 🔥 🔥 🔥 🔥

potatoqualitee added a commit that referenced this pull request Apr 10, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

Restore-DbaDatabase should be able to restore to a specific LSN

3 participants