Backing Up SQL Server Data Using the Command Line Interface

Log On to the CommServe

To run command line operations, you must first login to the CommServe.

From Command prompt, navigate to <Software_Installation_Directory>/Base and run the following command:

qlogin -cs <commserve name> -u <user name>

For example, to log on to CommServe 'server1' with username 'user1':

qlogin -cs server1 -u user1

Perform the Backup

  1. Download the backup_template.xml file and save it on the computer from where the command will be executed.

  2. Execute the following command from the <Software_Installation_Directory>/Base folder after substituting the parameter values.

    qoperation execute -af backup_template.xml -subclientName xxxxx -clientName xxxxx -instanceName xxxxx

  3. Verify the status of the job using the following command:

    qlist job -j jobID
  4. Once the job completes, log off from the CommServe using the qlogout command.

    qlogout [−cs <commserve_host_name>] [−all] [−tf <tokenfile>] [−tk <token>] [−h]
Examples

Performing a Full Backup

qoperation execute -af backup_template.xml -backupLevel FULL -subclientName subclient1 -clientName client1 -instanceName instance1

Performing a Transaction Log Backup

qoperation execute -af backup_template.xml -backupLevel INCREMENTAL -subclientName subclient1 -clientName client1 -instanceName instance1

Performing a Differential Backup

qoperation execute –af backup_template.xml –backupLevel DIFFERENTIAL -subclientName subclient1 -clientName client1 -instanceName instance1

Performing an On-Demand Backup

qoperation execute -af backup_template.xml -backupLevel FULL -subclientName subclient1 -clientName client1 -instanceName instance1 -ondemandinputfile C:\test\myDBsContent.txt

where myDBsContent.txt is an input file that list the databases as follows:

DB1

DB2

To run On-Demand backups for File/File Groups, the input file should list the database name, file group name and file name as follows:

DB1<tab>Group1<tab>File1inGroup1

DB1<tab>Group2<tab>File2inGroup1

Generate the Command Line Script from the CommCell Console

In addition to the parameter values provided in the template xml file, if you want to include additional options for the backup, you can do so by selecting the required options from the CommCell Console and generate the command line xml script for the backup.

Follow the steps given below to generate a script which you can use to perform a backup from the command line interface:

  1. From the CommCell Browser, navigate to Client Computers | <Client> | SQL Server | <Instance>.

  2. Right click an <Subclient> and click Backup.

  3. Select the required backup options which you want to execute using the script.

  4. Click Save as Script.

  5. Enter the location to save the script along with the file name and extension. For example, "C:\scripts\myscript.bat" on Windows and "/usr/scripts/myscript.sh" on Unix. Alternatively, you can also click Browse and navigate to the location.

    The script will be saved as a .xml file and .bat/.sh file.

    If a file with the same name already exists in the specified location, both the .xml and .bat/.sh files will be overwritten.

  6. Enter the username and password for the user account which you want to use to perform the backup.

    By default, the user account which you have used to login to CommCell console is used for performing the backup. However, if the user account does not have access to any application or database, click Use a different account.

  7. Click OK.

Log Off from the CommServe

Once you have completed the command line operations, you can logout from the CommServe using the following command:

qlogout -cs commserve

For example, to log out from the CommServe 'Server1'.

qlogout -cs Server1

Loading...