Command Line Interface - Restore - PostgreSQL iDataAgent

Generate the Command Line Script 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 by generating the script from the CommCell Console and saving it on the computer from where the restore will be performed.

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> | PostgreSQL | <Instance>.

  2. Right-click the <BackupSet>, and then click All Tasks | Browse and Restore.

  3. Click View Content.

  4. In the right pane of the Browse window, select the data that you want to restore and click Recover All Selected.

  5. Select the required restore options which you want to execute using the script.

  6. Click Save as Script.

    save_script - restoreklzzwxh:0257ostgresqlklzzwxh:0258ave_script.png

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

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

  9. Click OK.

    save_script2

Perform the Restore

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

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

  2. Navigate to the location where the .xml file is saved and execute the saved .xml script using the qoperation execute command.

    qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName xxxxx -backupsetName 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

Restoring Databases from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1' -sourceItem '/database2'

Restoring Schemas from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1/schema1/' -tableLevelRestore True

Restoring Tables from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1/public/tab1/' -tableLevelRestore True

Restoring Databases to an Auxiliary Database from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1/public/tab1/' -tableLevelRestore True -sourceDB 'database1' -auxillaryDB 'database2' -anyAuxilaryDatabase True

Restoring with 'Skip Import' Option from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1/public/tab1/' -tableLevelRestore True -staging True -stagingPath '/tmp' -importToServer True

Running Out-of-Place Restore from DumpBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1' -destinationInstance/ClientName 'client2' -destinationInstance/instanceName 'destinstance" -destClient/clientName 'client2'

Restoring Databases from FSBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/' -fsBackupSetRestore True

Running Out-of-Place Restore from FSBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/' -fsBackupSetRestore True -destinationInstance/ClientName 'client2' -destinationInstance/instanceName 'destinstance" -destClient/clientName 'client2'

Running Restore from FSBased Backupset without Starting the Server

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/' -fsBackupSetRestore True -startServer False

Running a Point-in-Time Restore from FSBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/' -fsBackupSetRestore True -pointInTime True -pointOfTime/timeValue '2021-07-22 14:22:00' -timeRange/toTime '2021-07-22 14:22:00'

Running a Volume-Level Restore from FSBased Backupset

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/' -fsBackupSetRestore True -volumeLeveRestore True -noOfStreams 3

Running a Table-Level Restore from Block-Level Enabled Subclient

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/database1/public/tab1/' -fsBackupSetRestore True -stagingPath '/tmp'

Running a Table-Level Restore with 'Skip Import' Option from Block-Level Enabled Subclient

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'DumpBasedBackupSet' -instanceName 'instance1' -subclientName 'default' -sourceItem '/database1/public/tab1/' -fsBackupSetRestore True -tableLevelRestore True -staging True -stagingPath '/tmp' -importToServer True

Running a Database-Level Restore to an Auxiliary Database from Block-Level Enabled Subclient

qoperation execute -af restore.xml -appName 'PostgreSQL' -clientName 'client1' -backupsetName 'FSBasedBackupSet' -instanceName 'instance1' -sourceItem '/database1/public/tab1/' -fsBackupSetRestore True -tableLevelRestore True -stagingPath '/tmp' -sourceDB 'database1' -auxillaryDB 'database2' -anyAuxilaryDatabase true

Loading...