Skip to content

Restore-DbaDatabase - Say that nothing was restored when the selection is empty - #10692

Merged
potatoqualitee merged 2 commits into
developmentfrom
fix-restore-empty-selection
Sep 12, 2026
Merged

Restore-DbaDatabase - Say that nothing was restored when the selection is empty#10692
potatoqualitee merged 2 commits into
developmentfrom
fix-restore-empty-selection

Conversation

@andreasjordan

Copy link
Copy Markdown
Collaborator

Fixes #10657

Problem

When the backup information pipeline selects nothing restorable - diff and log backups without the full that anchors the chain, or nothing newer than the continue point - Select-DbaBackupInformation stops. With -EnableException that throws since #10631. Without it, the stop is a warning, and Restore-DbaDatabase handed the empty selection on to the restore, which returned nothing. The only trace was the low-level "Fullname property not found" warning; the empty result looked like a successful restore, and a script that restores and then uses the database went on against a database that was never restored. The years-flaky Get-DbaDbRestoreHistory tests (#10620) were exactly this.

What changed

Option 2 from the issue: the command stops right after the selection when it is empty, with a warning that says so and names the database and instance:

Nothing to restore: the backup information selected no restorable backups for <db> on <instance>. A full backup has to anchor the chain (or -Continue has to point at a database restored with -NoRecovery), see the warning above for what was missing.

The warning from the selection still comes first and names what was missing. The check sits after -StopAfterSelectBackupInformation, so that switch keeps returning the (empty) selection as before.

What deliberately did not change

The contract. Without -EnableException this is still a warning and an empty result, so callers who point the command at possibly empty paths on purpose are not turned into failures (option 3 in the issue). With -EnableException nothing changes: the selection already throws before this check is reached. The empty-path case ("No backups passed through") already stopped with its own message since #10631 and is untouched.

Tests

The #10621 context in Restore-DbaDatabase.Tests.ps1 now asserts, without -EnableException, that both warnings are present and that the new one names the database, and gets a fourth test for the empty path without -EnableException (warns "No backups passed through", returns nothing). Through the testing-dbatools harness: green on both editions with the fix; red without the command change on the "Nothing to restore" assertion.

created by Claude and reviewed by Andreas Jordan

🤖 Generated with Claude Code

…n is empty

Without -EnableException, Select-DbaBackupInformation only warns when no
restorable backup is left - no full backup anchors the chain, or nothing is
newer than the continue point - and the command handed the empty selection
on to the restore, which returned nothing and looked like success. A script
that restores and then uses the database went on against a database that
was never restored.

The command now stops with a warning that names the database and says that
nothing was restored, right after the selection. The warning before it
still names what was missing. With -EnableException the selection already
throws since #10631, so that path is unchanged, and the contract stays a
warning: callers who point the command at possibly empty paths on purpose
are not turned into failures.

Fixes #10657

(do Restore-DbaDatabase)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@potatoqualitee potatoqualitee left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The empty-selection guard reports that no restore occurred without changing the existing EnableException behavior or normal restore paths. The regression test covers the concrete missing-full-backup case; unrelated MinIO failures do not affect this patch.

@andreasjordan

Copy link
Copy Markdown
Collaborator Author

The red s3-backup-tests check is not this PR: its MinIO setup step fails on the minio/minio image that is gone from Docker Hub, on every branch since 2026-09-11. Fix in #10688; an update of this branch after that merge turns the check green.

created by Claude and reviewed by Andreas Jordan

@potatoqualitee

Copy link
Copy Markdown
Member

fixed! thank you 🙏🏼

@potatoqualitee
potatoqualitee merged commit 88a4e5f into development Sep 12, 2026
17 of 18 checks passed
@potatoqualitee
potatoqualitee deleted the fix-restore-empty-selection branch September 12, 2026 11:40
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 - Empty backup selection is a silent no-op without -EnableException

2 participants