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-DbaDbMasterKey - Support Custom Backup File Name #9484

Open
serenefiresiren opened this issue Oct 1, 2024 · 2 comments · May be fixed by #9599
Open

Backup-DbaDbMasterKey - Support Custom Backup File Name #9484

serenefiresiren opened this issue Oct 1, 2024 · 2 comments · May be fixed by #9599
Labels
feature triage required New issue that has not been reviewed by maintainers

Comments

@serenefiresiren
Copy link
Contributor

serenefiresiren commented Oct 1, 2024

Summarize Functionality

SQL Command allows specifying the file name when backing up the service master key. Backup-DbaDbMasterKey currently automatically sets the filename. It would be nice to have the option here as well.
Relates to #9485, #9483

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

Yes

Technical Details

SQL

USE [YourDB];   
OPEN MASTER KEY DECRYPTION BY PASSWORD = 'DecryptionPassword';   
BACKUP MASTER KEY TO FILE = 'c:\temp\exportedmasterkey.key'   
    ENCRYPTION BY PASSWORD = 'EncryptionPassword';  

Existing File name command, Line 147
$filename = Join-DbaPath -SqlInstance $server -Path $actualPath -ChildPath "$fileinstance-$dbname-masterkey.key"

Suggested change adding an option Filename parameter

param (
        [DbaInstanceParameter[]]$SqlInstance,
        [PSCredential]$SqlCredential,
        [PSCredential]$Credential,
        [string[]]$Database,
        [string[]]$ExcludeDatabase,
        [Alias("Password")]
        [Security.SecureString]$SecurePassword,
        [string]$Path,
       **[string]$ChildPath,
       [Alias("FileName")]**
        [parameter(ValueFromPipeline)]
        [Microsoft.SqlServer.Management.Smo.Database[]]$InputObject,
        [switch]$EnableException
    )
#
#
#
# pseudo
$ChildPath = $ChildPath or if null then "$fileinstance-$dbname-masterkey.key"` 
$filename = Join-DbaPath -SqlInstance $server -Path $Path -ChildPath $ChildPath 
@wsmelton
Copy link
Member

wsmelton commented Oct 4, 2024

Is there any difference to you just running Rename-Item after the command?

@serenefiresiren
Copy link
Contributor Author

See #9485 for discussion

@niphlod niphlod linked a pull request Feb 22, 2025 that will close this issue
10 tasks
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

Successfully merging a pull request may close this issue.

2 participants