Command Line Interface - Restore - Sybase iDataAgent

Table of Contents

Perform the Restore

Note: You must perform step-by-step restores from the CommCell Console.

In order to run the restores from command line, you need an input xml file which contains the parameter values for configuring the restore options. This input xml file can be obtained using one of the following ways:

  • Download the input xml file template and save it on the computer from where the restore will be performed.
  • Generate the input xml file from the CommCell Console and save it on the computer from where the restore will be performed.

Use the following steps to perform the restore:

  1. Download the restore_template.xml file and save it on the computer from where the command will be executed.
  2. From Command prompt, navigate to <Software_Installation_Directory>/Base and run the following command:

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

  3. Execute the saved xml script using the qoperation execute command after substituting the parameter values.

    qoperation execute -af restore_template.xml -appName 'Sybase Database' -clientName xxxxx -instanceName xxxxx -destinationInstance/clientName xxxxx -destinationInstance/instanceName xxxxx -databaseId/name xxxxx

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

    qlist job –j JOBID

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

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

Examples

Restoring from a Current Backup

Use the following command to restore from the current backup.

qoperation execute -af restore_template.xml -appName 'Sybase Database' -clientName client1 -instanceName instance1 -destinationInstance/clientName client1 -destinationInstance/instanceName instance1 -databaseId/name db1

Restoring to a Different Client or Instance

Use the following command to restore to a different client or instance.

Note: The device path created on the destination server is same as the device path on the source server. To create a different device path on the destination server, see Rename a Database Restore.

qoperation execute -af restore_template.xml -appName 'Sybase Database' -clientName client1 -instanceName instance1 -databaseId/name db1 -destClient/clientName client2 -destinationInstance/clientName client2 -destinationInstance/instanceName instance2 -destinationServer/name instance2 -commonOptions/sybaseCreateDevices true

Restoring Databases to a Point-in-Time

Use the following command to restore to a point-in-time.

Note: If you do not provide the toTimeValue parameter, the latest backup is restored.

qoperation execute -af restore_template.xml -appName 'Sybase Database' -clientName client1 -instanceName instance1 -databaseId/name db1 -toTimeValue "yyyy-mm-dd hh:mm:ss" -destClient/clientName client2 destinationInstance/clientName client2 -destinationInstance/instanceName instance2 -destinationServer/name instance2

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> | Sybase.
  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.

Rename a Database Restore

Before You Begin

  • Create the devices on the destination server.

Procedure

  1. Run the qlogin command to log on to the CommServe computer.
  2. Download the rename_restore_template.xml file to the computer where you will run the command.
  3. Open the rename_restore_template.xml file, add your specific parameters, and save the file.

    For information on supported  XML parameters, see Available XML Parameters for Sybase Backups and Restores.

  4. On the command line, go to Software_Installation_Directory/Base and type the command.

    qoperation execute -af rename_restore_template.xml -clientName <source_client_name> -instanceName <source_instance_name> -destClient/clientName <destination_client_name> -destinationInstance/clientName <destination_client_name> -destinationInstance/instanceName <destination_instance_name> -destinationServer/name <destination_server_name> -databaseId/name <database_name> -devices <source subclientId>:<source dbId>:<source device Id>:<source device name>:<renamedDeviceName>:<renamed device Path>:<size of the device in bytes>:<renamed Database name> -renameDatabases true -databaseChain "0:<source dbId>:<database_name>:0" -sybaseCreateDevices true|false [-toTimeValue <timeValue> -pointInTime/timeValue]

  5. Verify the status of the job. On the command line type the command:

    qlist job –j <job_id>

  6. Once the job completes, run the qlogout command to log off the CommServe computer.

Finding a database ID from Sybase Dataserver

Login as Sybase SA user and execute the following SQL script:

isql -Usa –P<password>-S<Sybase server name> use master go select name, dbid from sysdatabases where name = ‘<dbname>’ go exit go

Finding an Endtime of the job for Point-in-time restore

Use the following command to find an end time of the job for Point-in-time restore:

./qoperation execscript -sn getjoblist.sql -si <clientName>

You will receive the list in the following format:

JOb ID

level

Status

StoragePolicyName

Retention Days

AppType Name

Subclient Name

Start Time/End Time

Active

12774 Full Success SP_Sybase -1 Sybase Database CRA 2012-08-28

20:06:37.00

No

The command output returns the UTC time and you need to convert this into CommServe (CS) time zone before using it in restore command.

Examples

Renaming a database restore without specifying a new device

qoperation execute -af rename_restore_template.xml -clientName sybserver3 -instanceName S155syb3 -databaseId/name db1 -destClient/clientName sybserver3 -destinationInstance/clientName sybserver3 -destinationInstance/instanceName S155syb3 -destinationServer/name S155syb3 -devices "0:0:0:0:0:0:0:new_db1" -renameDatabases true -databaseChain "0:0:db1:0" -sybaseCreateDevices false

Renaming a database restore by specifying new devices

qoperation execute -af rename_restore_template.xml -clientName sybserver3 -instanceName S155syb3 -databaseId/name db1 -destClient /clientName sybserver3 -destinationInstance/clientName sybserver3 -destinationInstance/instanceName S155syb3 -destinationServer/name S155syb3 -devices "0:14:0:db1:new_db1:/sybase/syb155/data/new_db1.dat:125829120:new_db1" -devices "0:14:0:db1_log:new_db1_log:/sybase/syb155/log/new_db1_log.dat:31457280:new_db1" -renameDatabases true -databaseChain "0:14:db1:0" -sybaseCreateDevices true

Renaming and restoring databases to a point-in-time

qoperation execute -af rename_restore_template.xml -clientName sybserver3 -instanceName S155syb3 -databaseId/name db1 -destClient/clientName sybserver3 -destinationInstance/clientName sybserver3 -destinationInstance/instanceName S155syb3 -destinationServer/name S155syb3 -devices "0:11:0:db1:db1:/Sybase/data/db1.dat:0:newdb1" -devices "0:11:0:db1_log:db1_log:/ sybase/log/db1_log.dat:0:newdb1" -renameDatabases true -databaseChain "0:11:db1:0" -sybaseCreateDevices false -toTimeValue "2015-11-24 16:00:00"

Renaming and restoring to a different client (cross server restore) to a point-in-time by specifying a new device

operation execute -af rename_restore_template.xml -clientName sybserver3 -instanceName S155syb3 -databaseId/name db1 -destClient/clientName sybserver4 -destinationInstance/clientName sybserver4 4 -destinationInstance/instanceName S155syb4 -destinationServer/name S155syb4 -devices "0:11:0:db1:test:/Sybase/data/test.dat:0:test" -devices "0:11:0:db1_log:test_log:/ sybase/log/test_log.dat:0:test" -renameDatabases true -databaseChain "0:11:db1:0" -sybaseCreateDevices false -toTimeValue "2015-11-20 13:00:00"

Renaming and restoring databases to a point-in-time of the transaction log backups

qoperation execute -af rename_restore_template.xml -clientName sybserver3 -instanceName S155syb3 -databaseId/name db1 -destClient/clientName sybserver4 -destinationInstance/clientName sybserver4 -destinationInstance/instanceName S155syb4 -destinationServer/name S155syb4 -devices "0:5:0:db1:newdb1:/sybase/syb155/data/newdb1.dat:104857600:newdb1" -devices "0:5:0:db_log:newdb1_log:/sybase/syb155/logs/newdb1_log.dat:20971520:newdb1" -renameDatabases true -databaseChain "0:5:db1:0" -sybaseCreateDevices true -toTimeValue "2015-11-23 10:00:00" -pointInTime/timeValue "2015-11-23 10:00:00"