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
Open

Backup-DbaDbMasterKey - Support Custom Backup File Name #9484

serenefiresiren opened this issue Oct 1, 2024 · 2 comments
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

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

2 participants