Command Line Interface - Restore - SQL Server iDataAgent

Configuration Backup Restore
Table of Contents

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 Restore

  1. Download the restore_template.xml file and save it on the computer from where the command will be executed.
  2. Execute the saved xml script using qoperation execute command.

    qoperation execute -af restore_template.xml -clientName kraken64 -instanceName kraken64 -toTimeValue 2011-11-28 15:40:00 -restoreSource ACC2 -database ACC2

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

    qlist job −j jobID

  2. Once the job completes, log off from the CommServe using the qlogout command.

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

Out-of-Place Restore on the Same SQL Server

  1. Download the out_of_Place_restore_template.xml file and save it on the computer from where the command will be executed.
  2. In the template locate the following section and edit it as per your setup:

    <device>|DB1|#12!DB1_rename|#12!DB1|#12! E:\RestoreLocation\DB1.mdf|#12!C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DB1.mdf </device>

    <device>|DB1|#12!DB1_rename|#12!DB1_log|#12! E:\RestoreLocation\DB1_log.ldf|#12!C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DB1_log.ldf </device>

    Where:
    • DB1 is the backed up database name.
    • DB1_Rename is the database name you want to provide for the restored database.
    • DB1 and DB1_log are the Logical Names of the backed up database.
    • E:\RestoreLocation is the destination path where you want to restore the database.
    • C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA is the source location of the backed up database.
  3. Execute the saved xml script using qoperation execute command.

    qoperation execute –af out_of_Place_restore_template.xml -clientName ida18 -instanceName ida18 -restoreSource DB1 -database DB1 -toTimeValue yyyy-mm-dd hh:mm:ss

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

    qlist job –j JOBID

  5. Once the job completes, logout from the CommServe using the qlogout command.

    qlogout [-cs commserver] [-all] [-tf tokenfile] [-tk token] [-h]

Out-of-Place Restore on a Different SQL Server

  1. Download the out_of_Place_restore_template.xml file and save it on the computer from where the command will be executed.
  2. In the template locate the following section and edit it as per your setup:

    <device>|DB1|#12!DB1_rename|#12!DB1|#12! E:\RestoreLocation\DB1.mdf|#12!C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DB1.mdf </device>

    <device>|DB1|#12!DB1_rename|#12!DB1_log|#12! E:\RestoreLocation\DB1_log.ldf|#12!C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\DB1_log.ldf </device>

    Where:
    • DB1 is the backed up database name.
    • DB1_Rename is the database name you want to provide for the restored database.
    • DB1 and DB1_log are the Logical Names of the backed up database.
    • E:\RestoreLocation is the destination path where you want to restore the database.
    • C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA is the source location of the backed up database.
  3. Execute the saved xml script using qoperation execute command, for example:

    qoperation execute -af out_of_Place_restore_template.xml -clientName ida18 -instanceName ida18 -restoreSource DB1 -database DB1 -toTimeValue yyyy-mm-dd hh:mm:ss -destClient/clientName RUBY -destinationInstance/clientName RUBY -destinationInstance/instanceName RUBY\Instance2

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

    qlist job –j JOBID

  5. Once the job completes, logout from the CommServe using the qlogout command.

    qlogout [-cs commserver] [-all] [-tf tokenfile] [-tk token] [-h]

Examples

Restoring from a Current Backup

qoperation execute -af restore_template.xml -clientName client1 -instanceName client1\instance1 -restoreSource DB1 -database DB1 –toTimeValue yyyy-mm-dd hh:mm:ss

Restoring Databases to a Point-in-Time (date and time)

qoperation execute -af pit_restore_template.xml -clientName client1 -instanceName client1\instance1 -restoreSource DB1 -database DB1 –toTimeValue yyyy-mm-dd hh:mm:ss

Restoring Database In-Place in Standby Mode

qoperation execute -af standby_inplace_restore_template.xml -clientName client1 -instanceName client1\instance1 -restoreSource DB1 -database DB2 -toTimeValue yyyy-mm-dd hh:mm:ss -sqlRecoverType STATE_STANDBY -renameFilesSuffix C:\UndoPath

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 restore, you can do so by selecting the required options from the CommCell Console and generate the command line xml script for the restore operation.

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

  1. From the CommCell Browser, navigate to Client Computers | <Client> | SQL Server.
  2. Right-click the <Instance> and then click All Tasks | Browse and Restore.
  3. Click View Content.
  1. In the right pane of the Browse window, select the data that you want to restore and click Recover All Selected.
  2. Select the required restore options which you want to execute using the script.
  3. Click Save as Script.
  1. 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.

  2. Enter the username and password for the user account which you want to use to perform the restore.

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

  3. Click OK.