Solved

Command line SQL backups for single database

  • 31 August 2021
  • 6 replies
  • 475 views

Userlevel 2
Badge +8

Hey all -

 

I am working with a customer and we have the command line backup for a SQL instance working just fine using an xml file.  What we can’t figure out is how do we do just 1 database on the instance?  We see the api call in command center but it doesn’t translate to the xml.  Anyone have the magic command?  We tried adding <databaseName>xxxx</databaseName> right under instance in the xml.

 

Attached a sample of the xml.

icon

Best answer by Gseibak 3 September 2021, 15:16

View original

6 replies

Userlevel 6
Badge +12

POST https://commserve/proxy/v2/sql/backup

 

{
  "backupType": "FULL",
  "instances": [
    {
      "sourceInstance": {
        "instanceId": 28,
        "instanceName": "SQL2\\PRODSQL2"
      },
      "selectedDatabases": [
        {
          "databaseId": 160,
          "databaseName": "AppStudioDB"
        }
      ]
    }
  ]
}

Userlevel 2
Badge +8

@MFasulo  how does this translate to the xml?  We did see this in API equivalent but this doesn't give me what I need.

 

Userlevel 6
Badge +12

I see the challenge.  Let me dig a bit into this.   Is there a reason to force XML or can you use JSON?

Userlevel 2
Badge +8

He is calling command line from within SQL studio.  I do understand how the APIs work, but how do we do that from within SSMS?  The command line was pretty easy to get working using qoperation execute.

 

Userlevel 4
Badge +11

Hi Melissa,

try adding this section in the XML -  you will need to replace the variables below with your config.

-<sqlDatabaseAssociation>

<databaseId>5</databaseId>

<databaseName>CommServ</databaseName>
-<associatedSubclient>

<subclientName>default</subclientName>

<backupsetName>defaultBackupSet</backupsetName>

<instanceName>CS1\COMMVAULT</instanceName>

<appName>SQL Server</appName>

<clientName>CS1</clientName>

<displayName>CS1LAB</displayName>

<commCellName>CS1LAB</commCellName>

<csGUID>21320A30-5383-4248-BF3D-AD1478A6C05F</csGUID>

</associatedSubclient>

 

you can also do a “save as” script from the subclient to generate the XML.

Userlevel 2
Badge +8

@Gseibak  just getting back to this so we will try again!  Customer was doing a POC so we had tabled it.  We will also be working with Marcus so I’m pretty sure he will know the answer!

Hope all is well!

Reply