Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup dbadatabase filepath name fix #7858

Conversation

jamesyip22
Copy link
Contributor

@jamesyip22 jamesyip22 commented Oct 12, 2021

Filepath variable was being cleared after first loop when using
ReplaceInName for multiple DBs

Type of Change

  • Bug fix (non-breaking change, fixes Backup-DbaDatabase - ReplaceInName doesnt work properly for multiple DBs #7857 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (effects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/sqlcollaborative/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

To fix the name templating when multiple databases going to be backed up. also updated the test to test for multiple DB backup event

Approach

$FilePath was getting set to $null after the first run of the loop, effectively breaking FilePath argument for any other databases that are getting backed up afterwards.

Commands to test

Backup-DbaDatabase -sqlinstance $new -database master,msdb -path C:\temp\ -filepath dbname.bak -replaceinname -outputscriptonly

Screenshots

image

Learning

Filepath variable was being cleared after first loop when using
ReplaceInName for multiple DBs
Added an additional DB for testing the name templating function and
created additional tests for it.
@potatoqualitee
Copy link
Member

potatoqualitee commented Oct 13, 2021

Thanks so much for the PR! Seems like all of our tests pass, too. But I wonder why that line was initially added. Should we qualify it with if (-not $ReplaceInName) {?

@jamesyip22
Copy link
Contributor Author

I don't see a reason why a provided argument should be cleared and there's no manipulation to it, definitely unsure why that line exists.

@potatoqualitee
Copy link
Member

Going to merge, thank you for being our 215th code contributor! 🙇🏼

@potatoqualitee potatoqualitee merged commit 3a74344 into dataplat:development Oct 18, 2021
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.

Backup-DbaDatabase - ReplaceInName doesnt work properly for multiple DBs
2 participants