Skip to main content

I’m trying to script a process to automate my restore testing of SQL Server database backups from Commvault.  The process will one-by-one restore each production database from all of my production servers to a utility server where I can run checkdb and other validation processes against the database and log the results.  I’m doing this all through powershell and using the Commvault powershell module RESTORE-CVSQLDATABASE to do the restore with the -OutofPlace flag and the other needed paramaters to tell it where to restore. So far it works fine as long as the original database data file directory and log file directories match my utility server.  Not so fine when they don’t.  It will throw an error in Commvault saying that it cannot find the datafile directory (H:\MSSQL\Data…..etc).  Of course there is no H drive on my utility server but that should be taken care of with the -DataFilePath "E:\MSSQL\Data" -LogFilePath "F:\MSSQL\Log" parameters I’ve passed in right?  Here’s the actual syntax of the command I’m using:

$jobids = (Restore-CVSQLDatabase -DatabaseObject $dbobject -OutofPlace -DestClientName $RestoreServer -DestInstanceName $RestoreServer -DestDatabaseName $DBName -DataFilePath "E:\MSSQL\Data" -LogFilePath "F:\MSSQL\Log" -Force).jobIds

Where $RestoreServer is my utility server name

Since there is not a lot of documentation on how to use the -OutofPlace parameters I’m making assumptions on their usage.  Anyone have any clues as to why this wouldn’t work?

The usage of Restore-CVSQLDatabase based on your assumptions is correct. Can you tell me what service pack or feature release your commserver is running?


@CGarcia Version 11 SP18.18


Unfortunately, the backend support for the out of place restore wasn’t fully implemented until 11.19.


@CGarcia Thanks for that info.  I’ll see if I can get my sysadmins to get that upgraded.


@AECI DBA  It’s very difficult to find example of SQL restore with PowerShell from Commvault.  Are-you welling to share your script? Or How explain how create the variable $dbobject ?

Best Regards

  


Hi, I am also having trouble using the Commvault SQL Powershell commands. I keep getting the below error…please advise. Thanks

PS C:\Backup> Get-CVSQLInstance -First 3

The property 'total' cannot be found on this object. Verify that the property exists.
At C:\Users\CVBackupUser1\Documents\WindowsPowerShell\Modules\Commvault.SQLServer\2.0.10\Commvault.SQLServer.psm1:1922 char:17
+                 $totalCount = $response.Content.response.total
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) Â], PropertyNotFoundException
    + FullyQualifiedErrorId : PropertyNotFoundStrict


Reply