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

Update Get-DbaFile.ps1 #9202

Merged
merged 1 commit into from
Jan 24, 2024
Merged

Update Get-DbaFile.ps1 #9202

merged 1 commit into from
Jan 24, 2024

Conversation

0x7FFFFFFFFFFFFFFF
Copy link
Contributor

@0x7FFFFFFFFFFFFFFF 0x7FFFFFFFFFFFFFFF commented Jan 7, 2024

Fix the bug:

PS C:\> Get-DbaFile -SqlInstance test -Path \\dc1\backup -FileType bak

Filename                                        SqlInstance
--------                                        -----------
\dc1\backup\AdventureWorks2016.bak              node1
\dc1\backup\AdventureWorks2016_202401072206.bak node1
\dc1\backup\db1_202401072154.bak                node1

PS C:\>

All SMB share paths should start with \\.

Please read -- recent changes to our repo

On November 10, 2022, we removed some bloat from our repository (for the second and final time). This change requires that all contributors reclone or refork their repo.

PRs from repos that have not been recently reforked or recloned will be closed and @potatoqualitee will cherry-pick your commits and open a new PR with your changes.

  • Please confirm you have the smaller repo (85MB .git directory vs 275MB or 110MB or 185MB .git directory)

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (affects 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/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

Approach

Commands to test

Screenshots

Learning

Fix the bug:

PS C:\> Get-DbaFile -SqlInstance test -Path \\dc1\backup -FileType bak

Filename                                        SqlInstance
--------                                        -----------
\dc1\backup\AdventureWorks2016.bak              node1
\dc1\backup\AdventureWorks2016_202401072206.bak node1
\dc1\backup\db1_202401072154.bak                node1

PS C:\>


All SMB share paths should start with '\\'.
if ($is_smb_share_path) {
$fullpath = $fullpath -replace "^\\", "\\"
}

Copy link
Member

Choose a reason for hiding this comment

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

I am trying to remember why even try to change the path separator from what SQL returns 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In SQL Server, you can create a database like this:


CREATE DATABASE [test]
ON PRIMARY
(
    NAME = N'test',
    FILENAME = N'C:\\Program Files\\Microsoft SQL Server\\MSSQL16.MSSQLSERVER\\MSSQL\\DATA\\test.mdf',
    SIZE = 8192KB,
    FILEGROWTH = 65536KB
)
LOG ON
(
    NAME = N'test_log',
    FILENAME = N'C:\\Program Files\\Microsoft SQL Server\\MSSQL16.MSSQLSERVER\\MSSQL\\DATA\\test_log.ldf',
    SIZE = 8192KB,
    FILEGROWTH = 65536KB
);

After creating the database, if you query the sys.database_files DMV, you will get a physical_name like C:\\Program Files\\Microsoft SQL Server\\MSSQL16.MSSQLSERVER\\MSSQL\\DATA\\test.mdf. Also, if there are flaws in your script when moving database files, you could encounter the same issues. It seems that the replace operation is intended to address these issues.

@wsmelton wsmelton changed the base branch from master to development January 24, 2024 17:34
@wsmelton
Copy link
Member

I'm not sure why the Action is stuck failing after the base branch is corrected in the PR.

@potatoqualitee
Copy link
Member

@wsmelton -- maybe its testing the SHA of the specific commit? Either way, I will merge it once appveyor passes bc I can't get it either.

@potatoqualitee potatoqualitee merged commit 3d0b877 into dataplat:development Jan 24, 2024
2 of 3 checks passed
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.

3 participants