Restoring PostgreSQL Databases to a Point-in-Time

If any undesired transaction occurs in the database, you can revert the database to a state just before the transaction. The point in time option enables you to restore the database to a specific point-in-time. Point-in-time restores are supported by FSBasedBackupSets only. This option is useful in the following scenarios:

  • If any undesired transaction occurs in the database, you can revert the database to a state just before the transaction.

  • If a database fails, you can restore to the state just before the point of failure.

  • You can restore multiple databases to a consistent time. This will be useful for the absolute synchronization of the databases.

When you perform a point-in-time restore for a database, the next scheduled backup for that database will automatically convert to a full backup.

  • Restore the File System backups of same version of PostgreSQL and not from higher to lower or lower to higher.

  • Before performing the point-in-time restore of a database, ensure that transaction logs for the database are backed up.

Procedure

  1. From the CommCell Browser, navigate to Client > PostgreSQL > Instance.

  2. Right-click the FSBasedBackupSet, and then click All Tasks > Browse and Restore.

  3. Click View Content.

  4. Select the databases you want to restore and click Recover All Selected.

    The PostgreSQL Database Restore Options dialog box is displayed.

  5. Select Restore in place. Click Next.

    By default, the server is restored to the data directory path according to the source data directory path. Port information and archive log directory information are obtained from the destination instance.

  6. In the Number of Streams box, enter the number of streams to use in the restore operation.

    By default, the number of streams is set to 2.

  7. To clean up data, tablespace, and archive log directories before performing the restore operation, select the Cleanup old directories check box.

    If you do not select the Cleanup old directories check box, stop the PostgreSQL server and delete or rename the data directory, user tablespace directory, archive log directory, and transaction log directory that is outside the data directory.

  8. To avoid starting the PostgreSQL Server automatically after the restore operation is complete, clear the Recover Database Server check box.

  9. To start the PostgreSQL Server, in the Custom start command box, enter the command.

    Examples:

    • On a RHEL computer, enter the systemctl start postgresql-15 custom command to start PostgreSQL as a service.

    • On a Window Server 2012 R2 computer, enter the sc start postgresql-x64-13 custom command to start PostgreSQL as a service.

      Note

      If you leave the Custom start command box empty, the Commvault software uses the pg_ctl command to start the PostgreSQL Server.

  10. Select the Point In Time check box.

  11. From the Restore Time list, select the date and time. The restore time selected must be later than the browse time.

  12. Click OK.

Note

  • For PostgreSQL V9.1 and later, if the parameter wal_level is set to hot_standby and the parameter hot_standby is set to ON in the postgresql.conf file, the restore operation is paused after reaching the specified time.

  • If the restore point is satisfactory, you can resume the restore operation by executing the pg_xlog_replay_resume file. Executing this file gets the server into the read and write mode instantly. For more information see KB article PSQL0013.

Page contents

×

Loading...