LogoLogo
EBR DocsHelp
Zmanda Classic
Zmanda Classic
  • Welcome to Zmanda Documentation
    • Zmanda Video Walkthrough
    • Zmanda 5.1 Release Notes
      • Zmanda 5.1.1 Release Notes
      • Zmanda 5.1.2 Release Notes
      • Zmanda 5.1.3 Release Notes
      • Zmanda 5.1.4 Release Notes
      • Zmanda 5.1.5 release notes
    • Zmanda 5.0 Release Notes
      • Zmanda Patch 5.0.0.7 Release Notes
      • Zmanda Patch 5.0.1.0 Release Notes
    • Zmanda 4.3 Release Notes
    • Zmanda 4.2 Release Notes
    • Zmanda 4.1 Release Notes
  • Getting Started With Zmanda
    • Terms, Concepts, and Best Practices
    • Cloud-Based Trial Environment
  • Installation & Configuration
    • Step 1: Install Zmanda Server
      • Dependencies & System Requirements
      • Zmanda Backup Appliance Installation
      • Oracle Cloud Marketplace Installation
      • AWS Marketplace Installation
      • Azure Marketplace Installation
      • Linux Binary Installation
      • Client-side Deduplication Documentation
      • Add Backup Servers in the ZMC
    • Step 2: Add Storage
      • Zmanda Cloud Storage
      • Simple Disk
      • NAS & SAN
      • Tape
      • Cloud Storage
    • Step 3: Add Sources
      • Prerequisite: Initialize a Backup Set
      • Windows
        • Installation
          • ZWC Silent Installation Guide
        • Configuration
      • Linux
        • Installation
        • Configuration
      • VMware and Hyper-V
      • File Shares
      • Databases and Applications
        • Oracle DB's - Linux
        • Oracle DB's - Windows
        • PostgreSQL Server - Linux
        • Microsoft SQL Server
        • Microsoft Exchange
        • Microsoft SharePoint
      • Mac OS
    • Step 4: Run a Backup
    • Step 5: Run a Restore
      • VMs Restore Process
      • PostgreSQL Restore Process
    • Step X: Intelligent Scheduling
    • Troubleshooting
  • Information
    • Backup Overview
      • Storage
      • Backup Sets
      • Sources
        • Large and complex data sources
      • Schedule Plan
    • Restore Overview
    • Disaster Recovery
      • Disaster Recovery with Zmanda: A Comprehensive Guide
    • Reports
    • Data Integrity
    • Custom Reports
    • Audit
    • License Info
    • Comprehensive Guide to Downloading Zmanda EBR 5.1 License
  • CUSTOMIZATION
    • How to Customize Your Zmanda Deployment
      • Vaulting
      • User Management
        • Single Sign-On Integration
        • LDAP Integration in Zmanda
        • Custom Roles and Policies
      • Enabling Email Notifications
      • Bulk Deployment of Zmanda Linux Clients
      • Bulk Deployment of Zmanda Windows Clients
      • Bulk Automation Guide
      • Immutable Backups
      • Global Exclusion Policy for Linux and Windows Clients
      • Client Triggered Oracle Backups
      • Archive to AWS Glacier Tiers
      • Comprehensive Guide to Setting Up Zmanda in AWS
      • Comprehensive Guide to Setting Up Zmanda in Azure
  • Product Lifecycle
    • Explore product lifecycle
Powered by GitBook
On this page
  • Steps to recover the data files to the destination directory
  • PostgreSQL Point-in-Time Recovery:
  • Follow these steps for Postgres version >= 12
  • Follow these steps for Postgres version <= 11

Was this helpful?

Export as PDF
  1. Installation & Configuration
  2. Step 5: Run a Restore

PostgreSQL Restore Process

PreviousVMs Restore ProcessNextStep X: Intelligent Scheduling

Last updated 12 months ago

Was this helpful?

LogoLogo

Quick Links

  • Amanda Community Wiki
  • Amanda Community Downloads
  • Share Feedback

About

  • About Us
  • Customer Testimonials

Terms

  • Terms of Use
  • Privacy Policy

Contact Info

  • Denver, CO, USA
  • 888-496-2632 (US)
  • 408-732-3208 (INT)

2025 © Zmanda, A BETSOL Company

Recovering a PostgreSQL database involves two crucial stages. The first step is to recover the data files to the destination directory on the client. The second step is to perform point-in-time recovery of the database using PostgreSQL tools.

Note: During the restoration process, it's essential to follow these precautions:

  1. Stop the PostgreSQL service before restoring files to the original location. After restoration, restart the PostgreSQL server.

  2. As a precaution, copy the files in the database directory to a temporary location.

  3. Ensure that all files and parent directories have correct read-write permissions and ownership as postgres:postgres.

Steps to recover the data files to the destination directory

  1. Stop the PostgreSQL service: Before starting the restoration process, halt the PostgreSQL service.

  2. Copy the PostgreSQL database directory: Move the PostgreSQL database directory to a temporary location by executing these commands.

# mkdir –p /var/lib/pgsql-restore/safeguard
# mv /var/lib/pgsql/14/data/ /var/lib/pgsql-restore/safeguard
  1. Initiate restoration:

  • Access the Restore tab and choose the backup set from the dropdown.

  • Select the backup you wish to restore from the Restore What page and proceed to the next step.

  1. Select destination directory: Choose the destination directory on the Restore Where page. By default, the temporary location is set to /tmp. If you wish to change this, toggle the option to Manual and specify the directory in the field provided.

Note:

  • Ensure both the Destination Directory and Temporary Directory have sufficient space to accommodate the selected backup data.

  • Avoid selecting the PostgreSQL data directory as the destination for your backup, especially if PostgreSQL is currently running and the files haven't been relocated elsewhere beforehand (see previous section for alternative locations). This could corrupt your data!

  1. Restore data: Select file and directory conflict options on the Restore How page. Proceed to the Restore Now page and initiate the restore process.

  1. Post restoration: After restoration, verify that the restore directory reflects the expected structure.

PostgreSQL Point-in-Time Recovery:

Note:

  • During the restoration process on Debian machines, rename the 'data' folder to 'main' as mandatory for versions 5.1.4.

  • Refer How to Get Your PostgreSQL Restore Ready for Zmanda 5.1 as mandatory for versions 5.1.3 and below. Version 5.1.4 does not require this step.

  • The PostgreSQL server must be stopped during this process and restarted afterward.

  • Move data: Move the data from the restore directory to the data directory of the Postgres server. Example: # mv /var/lib/pgsql/restore/data /var/lib/pgsql/14/

Follow these steps for Postgres version >= 12

  1. Edit postgresql.conf: Define a restore_command in postgresql.conf with the full path of the cp utility and the restore archive directory path.

    eg: restore_command = ‘<path to cp> path/to/restore/archive/%f "%p"’

  2. Create recovery.signal file: Create a blank recovery.signal file in the data directory to initiate recovery mode.

  3. Start PostgreSQL service: Start the PostgreSQL service to begin recovering from archived WAL files. If recovery stops due to errors, restart the server to continue.

Follow these steps for Postgres version <= 11

  1. Create recovery.conf File: Create the file recovery.conf in the data directory. Modify pg_hba.conf to prevent users from connecting until recovery is verified

Refer to the PostgreSQL documentation for detailed instructions: PostgreSQL Continuous Archiving and Point-in-Time Recovery Documentation.

  1. Edit recovery.conf: Modify recovery.conf file located at /var/lib/pgsql/11/data/ to include the restore_command entry specifying the path to the temporary archive directory. Run the following restore command:

<path to cp> /path/to/restore/archive/%f "%p
  1. Change ownership and permissions: Ensure that recovery.conf is owned by the database system user and has appropriate permissions. Change the ownership of the file to the database system user using the chown command:

# chown postgres:postgres /var/lib/pgsql/11/data/recovery.conf

Use chmod to limit file access to the database system user, allowing only read and write permissions using the following command.

# chmod 0600 /var/lib/pgsql/11/data/recovery.conf
  1. Start PostgreSQL service: Initiate the PostgreSQL service to commence recovery from archived WAL files. If recovery halts due to errors, restart the server to resume.

Inspect the database to verify its point-in-time status. Check the log sub-directory under the Postgres data directory for any recovery errors. If necessary, repeat the recovery process. Once verified, restore pg_hba.conf to its production state to allow end-user access.

  • For detailed information on PostgreSQL Point-in-Time Recovery, refer to the PostgreSQL Documentation: PostgreSQL: Documentation: 11: 25.3. Continuous Archiving and Point-in-Time Recovery (PITR)

  • For Amanda client versions 5.1, 5.1.1, and 5.1.2, refer to the KB article for instructions on performing incremental backups after recovery. This workaround is not required for Amanda client versions 5.1.3 and subsequent versions. Upgrading to the latest Amanda client binaries is highly recommended to avoid this workaround and benefit from potential improvements and bug fixes.

Following these steps will enable you to restore PostgreSQL.