How to access DDBoost with PowerShell

Hi,

We use DDBoost to backup and restore our databases to a storage like SAN.

How can I integrate PowerShell with DDBoost to backup or restore a database.

Here it is a sample T-SQL command thru DDboost to refresh a dev database from production DB on different server:


EXEC @returnCode = dbo.emc_run_restore ’

-a NSR_DFA_SI_DD_HOST=pezdd01 (It is where our databases’ backups are stored like SAN)

-a NSR_DFA_SI_DD_USER=DDboost (this is ddboost user which has access to the backups)

-a NSR_DFA_SI_DEVICE_PATH=/SQLBoost_UGL (path of the storage)

-a “NSR_DFA_SI_DD_LOCKBOX_PATH=C:\Program Files\DPSAPPS\common\lockbox”

-c ProdSERVER001 (Source (Prod DB) server )

-A DevSERVER001 (Target (Dev DB) server )

-a “SKIP_CLIENT_RESOLUTION=TRUE”

-C “’‘db_data’’=’‘I:\mssql\MSSQL12.MSSQLSERVER\MSSQL\DATA\TargetDB.mdf’’, ‘‘db_log’’=’‘J:\mssql\MSSQL12.MSSQLSERVER\MSSQL\Log\TargetDB_LOG.ldf’’”

-f -S normal -d MSSQL:TargetDB MSSQL:SOURCEDB’


Please let me know if need more clarification or detail.

Thanks and regards in advance.

Shoaib

Don’t know anything about DDBoost, but if its just an executable with some inputs, you can call it as if like you call it from any other shell(cmd.exe). More info on how you call DDBoost and its inputs will be good if you share and tell us the reason for opting PowerShell to execute this.

Hi KVParasoon,

Thanks for your prompt response.

Actually this para is taken from a job which could refresh a dev database from backup of production DB.

The reason to opt PS, there is no option to take input from users like which DB they want to refresh from which database i.e. TargetDB and SourceDB etc. in Script or Job in SQL Server Management Studio.

So my intention to take input in PS and then pass the values to T-SQL or CLI then integrate into the job, so a user would run the script or click the job to run manually.

Let me know if you need more info.

Thanks.

Shoaib

 

you can create a script which takes these values via Parameters and create the sql query, a small example would be

Param(
    [string]$TableName,
    [string]$Property,
    [string]$Server
)
$Query = @"
Select $Property from $TableName
"@

$Query | Out-File -FilePath c:\Query.sql

#Or calling an executable
c:\SomeFile.exe -s $Server -t $TableName -p $Property

You can do always everything in PowerShell, have fun automating your tasks…

Hi KVParasoon,

I have this sample script in PS, now please let me know how to pass these four values to SQL Script (T-SQL or CLI etc.):

$targetdb = read-host -Prompt 'Which DB do you want to refresh (Target DB) ’

$targetserver = read-host -Prompt 'on What server ’

$sourcedb = read-host -Prompt ‘Which DB do you want to refresh from (Source DB)’

$Sourceserver = read-host -Prompt 'What is the source server ’

Thanks again for your time.

Shoaib

We are happy to help you, but from above conversations what I understood is that you miss basic understanding of PowerShell, so please take your time to understand basics of PowerShell, since you have few requirements to complete, it will be an easy task for you, you can start from

  • https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-third-edition
  • https://mva.microsoft.com/liveevents/powershell-jumpstart