Skip to main content
Version 3.1.1

Backup Restoration

Command Syntax
Terminal input
pgsmart backup restore [Flags]

Flags:

  • -a, --agent=<agent> => Alias, hostname, or IP of the server where a PgSmart Agent is installed.
  • -b, --backup=<value> [default: All] => Backup identifier.
  • -h, --help => Help.
  • -q, --quiet => Non-interactive execution for backup operations (exec|info|restore). Used in conjunction with the --site and --agent options.
  • -s, --site=<value> [default: All] => Name of the backup environment.
  • -t, --type=(full|diff|incr) [default: incr] => Type of the backup.
    • full Backup of all files in the instance.
    • diff Backup of files in the instance that have changed since the last full backup.
    • incr Backup of files in the instance that have changed since the last backup, regardless of type.
  • --disable-archive => Indicates to disable archiving of WALs in the restored backup. Used in conjunction with the --quiet option.
  • --restore-path=<value> [default: Backup environment data directory] => Location where the backup will be restored. Used in conjunction with the --quiet option.
  • --restore-type=(delta|force) => Type of overwrite to be used, when there are files at the restore location. Used in conjunction with the --quiet option.
    • delta Overwrite the files using checksums.
    • force Completely overwrite the directory.
Non-interactive Restoration:
Terminal input
pgsmart backup restore -a <agent> -site <backup environment name> --backup <backup name> --quiet --restore-type=[delta|force]
Interactive Restoration
Terminal input
pgsmart backup restore
  1. Select the PgSmart agent (or register new Agent).

  2. PgSmart will perform a check, verifying if there is a registered backup environment. If not, it will allow the registration of a new environment.

  3. Select the backup environment.

note

PgSmart will validate the environment, checking if the database service is running, for example. However, it will not prevent the operation from proceeding (any irregularities found will be merely informative). This is because the restore is independent of the environment's situation.

3.1. PgSmart will present a list of backups for selection (indicating the most recent). 4. Select the desired backup.

note

The backup ID is created by pgBackRest and its composition is:

  • A prefix indicating the timestamp (date and time) of the backup creation in the format yymmdd-hhmmss.

  • A suffix "f", "i", or "d", indicating the type of backup (full, differential, incremental).

  • If the backup is incremental or differential, before the current backup ID, there will be the ID of the full backup from which it derives.

Example:

  • (full) 20230520-130807F

  • (incr) 20230520-130807F_20230520-130816I

  • (diff) 20230520-130807F_20230523-180002D

  • (full) 20230523-192605F (Most recent backup)

  1. After selecting the backup, confirm whether to use the standard PGDATA of the selected backup environment.
note

If the restoration directory is the same as that configured for the backup, PgSmart will check for running services in the instance (for which it will be necessary to confirm interruption, as restoration can only be performed with the service(s) offline).

  1. PgSmart will check for files in the directory and, if identified, it will be necessary to inform the desired action.
note

The possible actions are:

  • Overwrite using checksums: files in the destination directory that are the same as those in the backup will be kept, and only the different files will be restored. The result of the restoration will be a directory identical to that of the backup. (Delta backup with verifications done by checksums)

  • Completely overwrite: All files will be erased and recreated from the backup. The result of the restoration will be a directory identical to that of the backup, in the same manner.

Although both options lead to the same result, the difference between the two is the time of restoration. Overwriting will be quicker, since only the differences will be addressed.

  1. Confirm if WAL archiving should be disabled.

  2. Confirm the execution of the restoration.

    Figure 1 - Backup Restore
    Figure 1 - Backup Restore
Final Notes
note

If the restoration directory is different from that configured for the backup, PgSmart will check the directory for restoration and, in case it does not exist, will confirm its creation. If the creation is not confirmed, PgSmart will suspend the operation and return to the initial menu.

note
  • As WAL archiving is already enabled (the backup environment is already running), i.e., transaction logs are already being generated within the backup repository, restoring the backup in a new environment will restore the state of the PostgreSQL configuration parameters.

  • To prevent transaction logs from being recorded in an unwanted environment (in the production environment when the restoration is being done in a testing environment, for example), it is necessary to disable WAL archiving. This will ensure that PgSmart generates the transaction logs, recycling them within the instance directory, without posing risks to the environment.

note
  • The restoration can be verified directly in the directory:
Terminal input
  cd /var/lib/pgsql/15/data
  • To confirm the configuration parameters of the restore:
Terminal input
  cat postgresql.auto.conf