Archiving
Using WAL-G and pg_dump for archiving and restoration
Last updated
Was this helpful?
Using WAL-G and pg_dump for archiving and restoration
Last updated
Was this helpful?
**** is a simple and efficient archival restoration tool for PostgreSQL that simplifies and can store backups in S3, Google Cloud Storage, Azure, Swift, remote host (via SSH) or local file system.
In order to set up continuous backups, you need to do the following:
Configure wal-g
access to external storage.
Enable archiving of logs in Postgres and write the archive command:
archive_command = 'wal-g wal-push %p'
Make a base backup
wal-g backup-push $PGDATA
You can always restore the database from base backup if your database is corrupted.
Use to schedule backup process (daily, weekly, etc.).
To start rotating logs schedule this command using cron job:
wal-g
delete
retain FULL 30
This will delete all but 30 latest backups.
WAL-G includes "wal-verify" command that checks backup integrity.
You can use cron, Cronjob to schedule "wal-verify" execution.
Configure WAL-G access to external storage
Download backup wal-g
backup-pull
$PGDATA
Configure the wal-g wal-fetch
restore command
Start Postgres
Postgres downloads all the missing logs and reads them on start.
You can configure incremental backups with env variable WALG_DELTA_MAX_STEPS
.
So the backup will be faster, but the recovery process will take longer.
WAL-G is not a replacement of pg_dump
. pg_dump
is used to create a logical dump of one or several DBs in cluster.
WAL-G doesn't schedule backup automatically.
pg_dump
is a utility for backing up a PostgreSQL database.
It makes consistent backups even if the database is being used concurrently. pg_dump
only dumps a single database. To back up an entire cluster, or to back up global objects that are common to all databases in a cluster, use pg_dumpall
Dumps can be output in SQL script or archive file formats. Script dumps are plain-text files containing SQL commands required to reconstruct the database to the state it was in at the time pg_dump
was called.
Pick the JSON output of the command. The format is explained .
To restore a database feed the dump file.
The alternative archive file formats **** to restore the database.