SqlBak Blog

Top 9 simple PostgreSQL backup utilities for Linux

One of the key differences between PostgreSQL and other DBMSs is its large and diverse community, which creates a wide range of tools for working with and administering the system.

This is undoubtedly a good thing, but sometimes such variety can be overwhelming — many tools exist for the same task, and it’s not always clear which one to choose.

In this article, we provide an overview of PostgreSQL backup tools that are easy to set up. Please note: this is not an in-depth guide for each tool. Instead, we’ll show only the basic commands for creating a full database backup (although some of the tools are also capable of archiving WAL files effectively).

This overview includes only simple tools that are easy to get into, even without deep backend knowledge. For example, utilities like Barman and pgmoneta are not included here, as their configuration is more complex for straightforward full backups.

Let’s begin with the most basic and simple options, gradually moving toward more advanced solutions.

pg_dump

pg_dump – is a utility for creating logical backups of PostgreSQL. It is installed along with PostgreSQL in the directory containing the binary files. On Linux, the utility is automatically added to the system’s PATH variable and can be run directly from the command line.

Using this utility is very straightforward — you simply need to enter the following command in the terminal:

sudo su - postgres
pg_dump -U postgres  db_name > backup_file.sql

The restore process works as follows:

The database is deleted and re-created if it already exists

psql  -U postgres -c "drop database t1;create database t1;"

Restore the database

pg_restore -U postgres -d new_database_name -f backup_file.sql

Pros:

  • Very simple to use

  • Already installed by default

  • Creates human-readable logical backups

  • Allows restoration to a different PostgreSQL version

  • Supports backing up individual databases and tables

Cons:

  • Backup and restore processes are relatively slow

  • High server load during operation

pg_basebackup

pg_basebackup – this is a utility for creating physical backups of PostgreSQL. Like pg_dump, it is installed along with PostgreSQL in the directory containing binary files.

  • On Linux, it is usually added to the PATH environment variable by default and can be run directly from the command line.

  • On Windows, you need to specify the full path to the utility — typically found at:
    C:\Program Files\PostgreSQL\17\bin

pg_basebackup  --user=postgres  --pgdata=/backup/pg_base/

Essentially, the pg_basebackup utility simply performs a safe copy of the PostgreSQL server’s data directory to the directory specified in the --pgdata parameter.

Restoring is not entirely straightforward, but it can still be done with a simple script. The process usually involves stopping the PostgreSQL, deleting or moving the current data directory, copying the backup data directory back into place, setting the appropriate permissions, and then restarting the PostgreSQL server:

systemctl stop postgresql
mv /var/lib/postgresql/17/main /var/lib/postgresql/17/main_old
cp -R /backup/pg_base/ /var/lib/postgresql/17/main
chown -R postgres:postgres /var/lib/postgresql/17/main
systemctl stop postgresql

Pros:

  • Simple

  • Already installed

  • Fast backup and restore

Cons:

  • Cannot restore to a different PostgreSQL version

  • Backup individual schemas is not supported

pgAdmin

pgAdmin – is a web-based interface for managing PostgreSQL. It also allows you to create backups — in fact, pgAdmin runs pg_dump behind the scenes, but thanks to its user-friendly interface, you can easily choose various options and even select specific objects (such as individual tables) to back up.

If you already have pgAdmin installed, creating a basic backup is very straightforward 😊

  1. Open pgAdmin and connect to your PostgreSQL server.

  2. Navigate to the database you want to back up in the Object Explorer panel (left side).

  3. Right-click on the database and select “Backup…” from the context menu.

  4. In the Backup window, enter a filename (e.g., backup.sql), choose a format (Custom, Tar, or Plain), and optionally adjust other settings.

  5. Once ready, click the “Backup” button at the bottom-right corner.

Backup PostgreSQL database pgAdmin
Backup PostgreSQL database pgAdmin

To restore a backup, first create an empty database, and then perform the restore operation into that database:

Restore PostgreSQL database pgAdmin
Restore PostgreSQL database pgAdmin

Pros:

  • Simple and user-friendly interface

  • Creates easily readable logical backups

  • Supports backing up specific databases and tables

Cons:

  • Backup and restore are relatively slow

  • High server load during operations

  • Requires pgAdmin installation

SqlBak

SqlBak creates backups of PostgreSQL databases using pg_dump.

Follow these steps to create a scheduled backup job:

  1. Connect to your PostgreSQL server and click Create Job link:

    Create PostgreSQL connection SqlBak
    Create PostgreSQL connection

  2. In the opened Backup Job settings page in “Store backups in destinations” section, select where you want to store your backups. You can choose multiple destinations for redundancy.

    Add backup destinations SqlBak
    Add backup destinations

  3. In the “Schedule backups” section, define when and how often backups should run.

    Schedule backups SqlBak
    Schedule backups

  4. Set up alerts in the “Send email confirmation” section to get notified on success or failure.

  5. (Optional) Enable encryption and compression, add custom scripts, include local files/folders.

  6. Save and Run

    Run Backup Job SqlBak
    Run Backup Job

Currently, only full backups are supported for PostgreSQL Server databases.

To restore a backup, go to the “Backup History” section, find the desired backup, and click the “Restore” button in the Actions column:

Restore PostgreSQL backup SqlBak
Restore PostgreSQL backup

 

Pros:

  • Easy setup with centralized dashboard

  • Supports multiple backup destinations (cloud, FTP, local)

  • Scheduled backups with email notifications

  • White Label and automated deployment for MSPs

  • Works on Windows and Linux

Cons:

  • The free plan is limited to backup 2 databases

  • Agent installation required on each server

  • Limited command-line control

DbForge

dbForge – is a desktop utility for administering PostgreSQL. Most likely, your Linux server running PostgreSQL won’t have a graphical user interface, but you can connect to the PostgreSQL server remotely from another machine running Windows, Linux, or macOS.

With dbForge, you can not only run SQL queries but also compare data, generate test data, and perform various types of exports — which can serve as logical backups.

To perform an export, simply select the database → go to TasksExport. From there, you can choose from a variety of export formats:

The best format for backups is SQL. On the following tabs, you can also configure compression, encryption, and even set a retention period for your backups.

To restore a backup, simply create an empty database, then right-click on it and choose Tasks → Import, select the appropriate format, and specify the path to the backup file:

Pros:

  • Simple and user-friendly interface

  • Creates human-readable logical backups in a convenient format

  • Allows backing up specific databases and tables

  • Supports basic data transformations (e.g., renaming a column during export)

Cons:

  • Backup and restore processes are relatively slow

  • High server load during operation

  • Remote-only backup (since production Linux servers rarely have a GUI)

  • Paid software

Greenmask

Greenmask – is a utility primarily designed for data transformation. For example, if you need to transfer data from a production database to a test environment, Greenmask allows you to remove sensitive data during the backup process by defining removal rules in configuration files. Additionally, Greenmask can upload backups directly to S3.

Since the utility creates a logical dump, it can also be used for backups. To use it purely for backup purposes, you’ll need to create a configuration file where you define the rules for backup and restore. At the most basic level, it looks something like this:

common:
  pg_bin_path: "/usr/bin/"
  tmp_dir: "/tmp"

log:
  level: "info"
  format: "text"

storage:
  directory:
        path: "/tmp/pg_dump_test"
#  s3:
#    endpoint: "http://localhost:9000"
#    bucket: "testbucket"
#    region: "us-east-1"
#    access_key_id: "Q3AM3UASDAS1DQQA43P2F"
#    secret_access_key: "zuf+tfasdqwe1213xkitn121ifILbZam1KS23TG"

dump:
  pg_dump_options:
    dbname: "host=/run/postgresql user=postgres dbname=pagila"
    jobs: 10
    load-via-partition-root: true

restore:
  pg_restore_options:
    jobs: 10
    dbname: "host=/run/postgresql user=postgres dbname=pagila"

After creating the configuration, the backup is executed with a simple command:

./greenmask dump --config=config.yml

The restore is also performed with a straightforward command:

./greenmask restore --config=config.yml latest

Pros:

  • Ability to automatically transform data in backups

  • Fine-grained control over what to back up

  • Direct backup to S3

Cons:

  • Complex configuration for data transformation

  • High server load

WAL-E

WAL-E – is a tool designed for creating physical backups of various databases, including PostgreSQL. Its main advantage is the ability to send backups directly to cloud storage providers such as S3, Google Cloud Storage, and Azure. As the name suggests, WAL-E is built around handling WAL (Write-Ahead Logging) files — though that topic deserves its own article.

To perform a backup, you need to create a JSON configuration file that includes cloud storage credentials and PostgreSQL connection details:

{
    "WALE_S3_PREFIX": "s3://test-pranas-bucket/path/to/folder",
    "AWS_ACCESS_KEY_ID": "AXaksdjakdjkals12Y",
    "AWS_SECRET_ACCESS_KEY": "csd7as87d89a12d72as7d8aasd78as9d7sa89d",
    "WALE_COMPRESSION_METHOD": "brotli",
    "WALE_DELTA_MAX_STEPS": "5",
    "PGDATA": "/var/lib/postgresql/12/main",
    "PGHOST": "localhost",
    "PGUSER": "postgres",
    "PGPASSWORD": "********",
    "PGPORT": "5432"
}

In the backup command, you need to specify the backup-push subcommand, the path to the PostgreSQL data directory, and the path to the configuration file:

wal-e backup-push /var/lib/postgresql/14/main/ --config=/var/lib/postgresql/.walg.json

For restore, you need the same parameters, but use the backup-fetch command instead.:

systemctl stop postgresql
mv /var/lib/postgresql/17/main /var/lib/postgresql/17/main_old
wal-e backup-fetch /var/lib/postgresql/14/main/ LATEST --config=/var/lib/postgresql/.walg.json
chown -R postgres:postgres /var/lib/postgresql/17/main
systemctl stop postgresql

Pros:

  • Direct upload to cloud storage (S3, Google Cloud Storage, Azure)

  • WAL file management

  • Fast backup and restore directly from the cloud

Cons:

  • Backup individual schemas is not supported

  • Requires separate installation

  • Cannot restore to a different PostgreSQL version

pg_probackup

pg_probackup – this is a utility for performing physical backups of PostgreSQL. It is similar to pg_basebackup but offers additional features such as differential backups and the ability to back up remote servers via SSH.

It’s particularly convenient to use when you have a dedicated backup server and a separate server running the PostgreSQL database. You need to install the utility on both servers, configure access for the postgres user from the backup server, and then run an initialization command once:

pg_probackup-16 add-instance -B /mnt/backups -D /var/lib/postgresql/16/main --instance=node --remote-host=138.68.82.125 --remote-user=postgres

after which you can start making backups:

pg_probackup-16 backup -B /mnt/backups -b FULL --instance=node --stream --compress-algorithm=zlib --remote-host=138.68.82.125 --remote-user=postgres -U postgres -d postgres

During restore, the pg_probackup utility will automatically stop the PostgreSQL server and prepare everything for the restore. The restore itself is performed with a simple command:

pg_probackup-16 restore -B /mnt/backups -D /var/lib/pgpro/std-16/staging-data --instance=node --remote-host=138.68.82.125 --remote-user=postgres

Pros:

  • Supports incremental and differential backups (unlike pg_basebackup, which supports them only from version 17)

  • Physical backup of remote servers via SSH

  • Fast restore and recovery

  • Automatic deletion of old backups during backup process

Cons:

  • Initial setup is not straightforward

  • Many advanced features are available only with Postgres Pro edition

pgBackRest

pgBackRest – is an advanced utility that can automate PostgreSQL server backups, automatically delete old backups, and supports parallel, incremental, and differential backups, as well as backups of remote servers.

pgBackRest is not a simple tool, and it takes time to fully understand it. However, if you only need basic backup functionality, setting it up is not overly complicated.

To get started, you need to create a configuration file at /etc/pgbackrest/pgbackrest.conf, where you specify the backup storage location, the number of backups to retain, and the path to the PostgreSQL data directory:

[global]
repo1-path=/var/lib/pgbackrest
repo1-retention-full=2
[demo]
pg1-path=/var/lib/postgresql/16/main

After that, you can start performing backups:

sudo -u postgres pgbackrest --stanza=demo --log-level-console=info backup

The restore command is just as simple:

sudo -u postgres pgbackrest --stanza=demo restore

Pros:

  • Supports incremental and differential backups (while pg_backupdatabase supports it only from version 17)

  • Physical backup of remote servers

  • Fast recovery and restore

  • Allows restoring a single database from a backup (not just the whole cluster)

Cons:

  • Initial setup is not straightforward

Conclusion

PostgreSQL offers a wide variety of backup tools — from built-in utilities like pg_dump and pg_basebackup, to more advanced solutions such as pgBackRest, pg_probackup, and cloud-integrated tools like WAL-E, Greenmask, and SqlBak.

Choosing the right tool depends on your technical comfort level, infrastructure, and recovery requirements — but the good news is, PostgreSQL’s ecosystem has you covered either way.

Leave a Comment