Skip to main content
Question

Restore database XML API versus qoparation : different behaviour


Forum|alt.badge.img+2

Hi all,

A few months ago I came here to be able to restore sql server databases using the API instead of the qcommands

https://community.commvault.com/commvault-setup-guides-and-getting-started-51/run-qoperation-exe-from-remote-server-5379

So I have the xml file to restore the database and I have a STOPAT parameter.

In the xml it shows like this :

            <pointInTime>
              <timeValue>2023-05-19 09:54:04</timeValue>
            </pointInTime>

 

My xml file works if I run sth like :

qoperation.exe" execute -cs $CVLTServer -af $CVLTXMLFile -tf $CVLTToken

 

Then it doesn’t if I run :

$cvrestendpoint = "http://$CVLTServer:81/SearchSvc/CVWebService.svc" 
$token = (Get-CVSessionDetail 'Get-CVVersionInfo').sessionToken
$restParameters = @{# Variables for holding rest parameters for the request
    URI     = ""
    Method  = ""
    Headers = @{"Authtoken" = $token;"Accept"    = "application/json"}
    body = ""
}

Get-Variable | Where-Object {$_.name -eq '$xml'} | Remove-Variable
$xml = get-content CVLTXMLFile

        $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
        $result.jobIds

 

I get the error :

Error Code: [19:861] Description: Killed by . Reason:[]. Source: , Process: JobManager  Query Result [Microsoft.SqlServer.Management.Common.ExecutionFailureException:
The specified STOPAT time is too early. All or part of the database is already rolled forward beyond that point.
RESTORE LOG is terminating abnormally. An exception occurred while executing a Transact-SQL statement or batch.]. Source: wesvsqlu001-bkp, Process: SQLRestore  

 

My sql trace gives me the script run on the instance :

RESTORE LOG [mydb] FROM VIRTUAL_DEVICE = 'c48643e5-05aa-44b2-9328-1cfdd41b3e6e', VIRTUAL_DEVICE = 'c48643e5-05aa-44b2-9328-1cfdd41b3e6e_1' 
WITH NORECOVERY, MAXTRANSFERSIZE=2097152, BLOCKSIZE=65536, BUFFERCOUNT=20, STOPAT = '01-01-1970 01:00:00', REPLACE, ...
go

 

You’ll note the :

STOPAT = '01-01-1970 01:00:00'

 

I have tried reformatting the date for different cultures and nothing helps.

It starts to look like a bug.

Anyone can help me here ?

 

thanks,

 

 

 

 

 

 

3 replies

Emils
Vaulter
Forum|alt.badge.img+12
  • Vaulter
  • 147 replies
  • May 29, 2023

Hi @mdaniou 

Thanks for reaching out.

Can you please confirm you’re using the  pit_restore_template.xml?

https://documentation.commvault.com/2022e/expert/18366_restoring_sql_server_agent_using_command_line_interface.html

As this will also have the following variable set to true:

<pointOfTimeRst>true</pointOfTimeRst>


Forum|alt.badge.img+2
  • Author
  • Bit
  • 5 replies
  • May 31, 2023

Hi,

 

Yes I am.

 

 


Emils
Vaulter
Forum|alt.badge.img+12
  • Vaulter
  • 147 replies
  • June 1, 2023

Thanks @mdaniou 

I would recommend engaging support to help troubleshoot why the XML is not working as expected.

Thank you


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings