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 : add a switch that will prevent to always append dbname in the directory backup path and strictly respect the given path variable. #9346

Open
rferraton opened this issue May 13, 2024 · 0 comments
Labels
feature triage required New issue that has not been reviewed by maintainers

Comments

@rferraton
Copy link
Contributor

rferraton commented May 13, 2024

Summarize Functionality

For the command Backup-DbaDatabase, add a switch that will prevent to always append dbname in the directory backup path and strictly respect the given path variable.

Cause : Currently, Backup-DbaDatabase always appended the DbName in the backup path. This can be problematic in some cases where the backup path try to respect Ola Hallengren default path model and when the database name is long. In this case the current dbname appending lead to repeat the dbname twice in the backup path and can cause a "backup path too long" error.

Suggested switch name -NoAppendDbNameInPath
Default value would remain false to avoid impact on the existing backups scripts

Is there a command that is similiar or close to what you are looking for?

Yes

Technical Details

line 664 in Backup-DbaDatabase.ps1 :

if ($CreateFolder -and $FinalBackupPath[0] -ne 'NUL:') {
                for ($i = 0; $i -lt $FinalBackupPath.Count; $i++) {
                    $parent = [IO.Path]::GetDirectoryName($FinalBackupPath[$i])
                    $leaf = [IO.Path]::GetFileName($FinalBackupPath[$i])
                    if ($NoAppendDbNameInPath) {
                        $FinalBackupPath[$i] = [IO.Path]::Combine($parent, $leaf)
                    } else {
                    $FinalBackupPath[$i] = [IO.Path]::Combine($parent, $dbName, $leaf)
                    }
                }
            }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature triage required New issue that has not been reviewed by maintainers
Projects
None yet
Development

No branches or pull requests

1 participant