Solved

Run QOperation.exe from remote server


Badge +2

Hi,

I need to use the command QOperation.exe and others that are on the Commvault server under \ContentStore\Base .

How do I make them available on my remote server ?

Thanks for the help,

br

icon

Best answer by christopherlecky 6 March 2023, 17:18

View original

10 replies

Userlevel 3
Badge +10

What are you trying to do?

Badge +2

I have a powershell script that uses QOperation.exe to run restores and I have a requirement to be able to run it outside of the commvault box.

Hence my need to have these on the remote server.

Userlevel 5
Badge +16

I have a powershell script that uses QOperation.exe to run restores and I have a requirement to be able to run it outside of the commvault box.

Hence my need to have these on the remote server.

Do it via rest. That will make your scripts portable.

You can do something like this :

 

 

$cvrestendpoint = "http://" + $cs + ":81/SearchSvc/CVWebService.svc"

$restParameters = @{# Variables for holding rest parameters for the request
URI = ""
Method = ""
Headers = @{"Authtoken" = $token;"Accept" = "application/json"}
body = ""
}



$newSubclientXML = '<?xml version="1.0" encoding="UTF-8" ?>
<root>
<App_CreateSubClientRequest>
<subClientProperties>
<subClientEntity>
<appName>'+$appname+'</appName>
<backupsetName>'+$backupsetName+'</backupsetName>
<clientName>'+$clientName+'</clientName>
<instanceName>'+$instanceName+'</instanceName>
<subclientName>'+$subclientName+'</subclientName>
</subClientEntity>
<contentOperationType>ADD</contentOperationType>
<commonProperties>
<numberOfBackupStreams>'+$numberOfBackupStreams+'</numberOfBackupStreams>
<storageDevice>
<dataBackupStoragePolicy>
<storagePolicyName>'+$storagePolicyName+'</storagePolicyName>
</dataBackupStoragePolicy>
</storageDevice>
</commonProperties>
<content>
<path>'+$path+'</path>
</content>
</subClientProperties>
</App_CreateSubClientRequest>
</root>'


try{ #Create Subclient
$restParameters.URI = $cvrestendpoint + "/Subclient/"
$restParameters.Headers.'Content-Type' = 'application/xml'
$restParameters.Method = "POST"
$restParameters.Body = $newSubclientXML
$result = Invoke-RestMethod @restParameters
$newsubclient = $result.response.entity

}
catch{
if($error[0].Exception.Response.StatusCode -eq "Conflict"){
write-host "Destination subclient ["$subclientName"] already exists"
}else{
write-host "Destination subclient ["$subclientName"] could not be created"}

}

This an analogous with the qoperation post api.

you would change the xml obviously and use this api

 

Userlevel 5
Badge +16

To answer your question directly, you would need to install the base client agent on any server that you wish to use qoperation. 

 

Using the API removes the need create a client, all you need is network access and credentials. 

This is especially helpful if you siloed in such a way where getting clients installed is difficult.

Badge +2

Thanks for the answer.

As for the API, I agree that it would be a solution too.

The problem is that I have worked on that a few months ago to restore sql server databases and the option to relocate the log files was not reliable (meaning buggy). I had to give it up.
The log files were relocated in the data folder instead.
https://github.com/Commvault/CVPowershellSDK/issues/27

Aside this my process uses API for a few other operations.

Userlevel 5
Badge +16

Thanks for the answer.

As for the API, I agree that it would be a solution too.

The problem is that I have worked on that a few months ago to restore sql server databases and the option to relocate the log files was not reliable (meaning buggy). I had to give it up.
The log files were relocated in the data folder instead.
https://github.com/Commvault/CVPowershellSDK/issues/27

Aside this my process uses API for a few other operations.

I didn’t suggest using the SDK. 

Just rest. The code I shared are just api calls passed via rest.

In other words you can submit the same qoperation as you would via command line. 

I personally don’t use the SDK.

Badge +2

I understand.

I’ll need to have a closer look then.

Userlevel 5
Badge +16

I understand.

I’ll need to have a closer look then.

The SDK simplifies tasks, if you are running into an issue with the SDK you can always use an api call as an alternative.

Badge +2

Hey Christopher,

Just wanted to thank you for your suggestion. I managed to run a restore using your tips.

I adapted your bit of code and here is what I have (for the record) :

$restParameters = @{# Variables for holding rest parameters for the request
URI = ""
Method = ""
Headers = @{"Authtoken" = $token;"Accept" = "application/json"}
body = ""
}

$xml = get-content 'MyXml.xml'

$restParameters.URI = $cvrestendpoint + "/ExecuteQCommand"
$restParameters.Headers.'Content-Type' = 'application/x-www-form-urlencoded'
$restParameters.Method = "POST"
$restParameters.Body = "command=qoperation%20execute&inputRequestXML=" + $xml
$result = Invoke-RestMethod @restParameters
$newsubclient = $result.response.entity

 

The body needs to start with “command=qoperation%20execute&inputRequestXML=”

I need to implement that now but it seems like this is the way to go for me.

Thanks again

Userlevel 5
Badge +16

No problem.

Reply