Back up PostgreSQL to NordenVault
Three approaches, from simple to production-grade. All store your backups in EU data centres with encryption at rest.
Prerequisites
- A NordenVault account with S3 credentials (access key and secret key)
- Your NordenVault bucket name (visible in the dashboard under Credentials)
- PostgreSQL running on the server you want to back up
Your S3 endpoint is s3.nordenvault.com
Option 1: pg_dump + rclone
Best for small to medium databases (under 100 GB). Simple to set up, easy to automate with cron.
Install rclone
# Debian/Ubuntu
sudo apt install rclone
# macOS
brew install rcloneConfigure rclone
cat >> ~/.config/rclone/rclone.conf << 'EOF'
[nordenvault]
type = s3
provider = Other
endpoint = https://s3.nordenvault.com
access_key_id = YOUR_ACCESS_KEY
secret_access_key = YOUR_SECRET_KEY
region = us-east-1
EOFRun a backup
# Dump the database in custom format (compressed)
pg_dump -Fc mydb > /tmp/mydb.dump
# Upload to NordenVault
rclone copy /tmp/mydb.dump nordenvault:YOUR_BUCKET/postgres/
# Verify the upload
rclone ls nordenvault:YOUR_BUCKET/postgres/Restore
# Download the backup
rclone copy nordenvault:YOUR_BUCKET/postgres/mydb.dump /tmp/
# Restore into a new database
createdb mydb_restored
pg_restore -d mydb_restored /tmp/mydb.dumpAutomate with cron
# Run daily at 2 AM
0 2 * * * pg_dump -Fc mydb > /tmp/mydb-$(date +\%Y\%m\%d).dump && rclone copy /tmp/mydb-$(date +\%Y\%m\%d).dump nordenvault:YOUR_BUCKET/postgres/ && rm /tmp/mydb-*.dumpOption 2: WAL-G
Continuous archiving with point-in-time recovery. Recommended for production databases where RPO matters.
Install WAL-G
# Download the latest release
curl -sL -o /usr/local/bin/wal-g \
https://github.com/wal-g/wal-g/releases/download/v3.0.3/wal-g-pg-ubuntu-20.04-amd64
chmod +x /usr/local/bin/wal-gConfigure environment
Add these to your PostgreSQL server's environment (e.g. /etc/environment or the systemd unit file):
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
AWS_ENDPOINT=https://s3.nordenvault.com
AWS_S3_FORCE_PATH_STYLE=true
AWS_REGION=us-east-1
WALG_S3_PREFIX=s3://YOUR_BUCKET/walg
WALG_COMPRESSION_METHOD=lz4Configure PostgreSQL
Edit postgresql.conf:
wal_level = replica
archive_mode = on
archive_command = 'wal-g wal-push %p'Restart PostgreSQL after changing these settings.
Run a base backup
# Run as the postgres user
sudo -u postgres wal-g backup-push /var/lib/postgresql/16/main
# List backups
sudo -u postgres wal-g backup-listRestore
# Stop PostgreSQL
sudo systemctl stop postgresql
# Clear the data directory
sudo -u postgres rm -rf /var/lib/postgresql/16/main/*
# Restore the latest backup
sudo -u postgres wal-g backup-fetch /var/lib/postgresql/16/main LATEST
# Create recovery signal
sudo -u postgres touch /var/lib/postgresql/16/main/recovery.signal
# Start PostgreSQL (it will replay WAL segments)
sudo systemctl start postgresqlAutomate
# Cron: full backup every night, WAL segments archive continuously
0 3 * * * sudo -u postgres wal-g backup-push /var/lib/postgresql/16/main
# Optional: delete old backups (keep last 7)
0 4 * * * sudo -u postgres wal-g delete retain FULL 7 --confirmOption 3: pgBackRest
Full-featured backup tool with incremental backups, parallel compression, and encryption. Best for large databases.
Install pgBackRest
# Debian/Ubuntu
sudo apt install pgbackrest
# RHEL/Rocky
sudo dnf install pgbackrestConfigure
Create /etc/pgbackrest/pgbackrest.conf:
[mydb]
pg1-path=/var/lib/postgresql/16/main
pg1-port=5432
pg1-user=postgres
[global]
repo1-type=s3
repo1-s3-endpoint=s3.nordenvault.com
repo1-s3-bucket=YOUR_BUCKET
repo1-s3-key=YOUR_ACCESS_KEY
repo1-s3-key-secret=YOUR_SECRET_KEY
repo1-s3-region=us-east-1
repo1-s3-uri-style=path
repo1-path=/pgbackrest
repo1-retention-full=4
repo1-cipher-type=aes-256-cbc
repo1-cipher-pass=YOUR_ENCRYPTION_PASSPHRASE
[global:archive-push]
compress-level=3Configure PostgreSQL
# postgresql.conf
wal_level = replica
archive_mode = on
archive_command = 'pgbackrest --stanza=mydb archive-push %p'Initialize and back up
# Create the stanza (one-time setup)
sudo -u postgres pgbackrest --stanza=mydb stanza-create
# Run a full backup
sudo -u postgres pgbackrest --stanza=mydb --type=full backup
# Check status
sudo -u postgres pgbackrest --stanza=mydb infoRestore
# Stop PostgreSQL
sudo systemctl stop postgresql
# Restore (pgBackRest handles everything)
sudo -u postgres pgbackrest --stanza=mydb restore
# Start PostgreSQL
sudo systemctl start postgresqlAutomate
# Full backup weekly, incremental daily
0 3 * * 0 sudo -u postgres pgbackrest --stanza=mydb --type=full backup
0 3 * * 1-6 sudo -u postgres pgbackrest --stanza=mydb --type=incr backupWhich option should I choose?
pg_dump + rclone if you want something simple and your database is under 100 GB. Logical backups are portable across PostgreSQL versions.
WAL-G if you need continuous archiving and point-in-time recovery. Lightweight and fast.
pgBackRest if you need incremental backups, built-in encryption, parallel compression, and backup verification. The most complete option for large production databases.