Skip to main content
Version Next

Backup Restoration

Command Syntax
Terminal input
  pgsmart backup restore [Flags]

Flags:

  • -a, --agent=<agent> => Alias, hostname, or IP of the server where the desired PgSmart Agent is installed.
  • -b, --backup=<value> => Backup identifier. [default: All]
  • -h, --help => Help
  • -j, --job=<value> => Backup/restore job identifier.
  • -o, --only-info => Displays only backup site information. Used with the --quiet option.
  • -p, --no-page-info => Indicates not to paginate backup site information. Used with the --quiet option.
  • -q, --quiet => Non-interactive execution for backup operations (exec|info|restore). Used with the --site and --agent options.
  • -s, --site=<value> => Backup site name. [default: All]
  • --disable-archive => Disables WAL archiving for the restored backup. Used with the --quiet option.
  • --restore-path=<value> => Path where the backup will be restored. [default: Backup site's data directory] Used with the --quiet option.
  • --restore-type=(delta|force) => Overwrite mode if files already exist in the restore location. Used with the --quiet option.
    • delta: Overwrite using checksums.
    • force: Fully overwrite the directory.
Non-Interactive Execution
Terminal input
    pgsmart backup restore -a <agent> --site <backup-site-name> --backup <backup-name> --quiet --restore-type=[delta|force]
Figure 1 - Backup Restoration
Figure 1 - Backup Restoration
Interactive Execution
Terminal input
    pgsmart backup restore
  1. Select the desired PgSmart Agent (or Register a new Agent).

  2. PgSmart will validate if there is a registered backup site. If not, it will allow registering a new site.

  3. Select the backup site.

3.1. PgSmart will list available backups to select the desired one (highlighting the most recent).

note

PgSmart will validate the site, checking aspects such as whether the database service is running, for example. However, it will not block the operation if any irregularity is found (informational only). Restoration does not depend on the site status.

  1. Select the desired backup.

    note

    Backup IDs are generated by pgBackRest and consist of:

    • =A prefix representing the timestamp (YYMMDD-HHMMSS) of when the backup was created.
    • A suffix "F", "I" or "D", indicating full, incremental, or differential backup.
    • For incremental/differential backups, the full backup ID precedes the current backup ID.

    Example:

    • (full) 20230520-130807F
    • (incr) 20230520-130807F_20230520-130816I
    • (diff) 20230520-130807F_20230523-180002D
    • (full) 20230523-192605F (Most recent backup)
  2. After selecting the backup, confirm if you want to use the default PGDATA path from the selected backup site.

    note

    If restoring to the same directory configured for backups, PgSmart will check for running services and request confirmation to stop them, as the restore requires all services offline.

  3. PgSmart will check if files already exist in the target directory. If so, you must specify the overwrite action.

note

Possible actions:

  • Checksum-based overwrite: only files with differences are replaced, resulting in a directory identical to the backup.
  • Fully overwrite: the entire directory is deleted and recreated from the backup.

Both methods lead to the same final result; however, checksum overwrite is faster as it handles only changed files.

  1. Confirm whether WAL archiving should be disabled.

  2. Confirm the execution of the restore process.

    Figure 1 - Backup Restoration
    Figure 1 - Backup Restoration
Final Notes
note

If the restoration directory is different from the one configured for backups, PgSmart will validate the directory. If it does not exist, confirmation for creation will be required. If creation is declined, PgSmart will cancel the operation and return to the main menu.

note
  • Since WAL archiving is already enabled (the backup site is active), restoring a backup into a new site will restore the PostgreSQL configuration parameters as well.

  • To avoid transaction logs from being written into the wrong environment (e.g., restoring in a testing environment while connected to production), WAL archiving should be disabled. This ensures that transaction logs are only managed locally in the instance's directory, avoiding risks.

note

The restoration can be verified directly in the directory:

Terminal input
    cd /var/lib/pgsql/15/datann

To confirm the restored configuration parameters:

Terminal input
    cat postgresql.auto.conf