PostgreSQL backups with WAL-G

WAL-G ships PostgreSQL base backups and WAL archives to object storage so you can restore to a point in time. This page covers what it does, how to configure it, and how it compares with pgBackRest in day-to-day operations.

On this page

PostgreSQL backups with WAL-G: when a team needs it and what it does

A self-hosted PostgreSQL team needs WAL-G when it has a recovery point objective and a recovery time objective to meet and must keep copies of its data off the primary host. WAL-G is an open-source backup tool that pushes base backups and archived write-ahead log (WAL) to object storage in S3, GCS or Azure. That places the copies in a separate location from the database server, so a failed disk, a lost host or a damaged data directory does not take the backups with it. Before adopting it, confirm that your storage provider, network path and credentials meet the requirements of your recovery plan, and that your team can operate the tool without a dedicated backup host.

Point-in-time recovery needs two things from the archive. The first is a base backup, a copy of the data directory taken while the server runs. The second is the continuous series of WAL files written after that backup started. The continuous archiving documentation describes how PostgreSQL hands each completed WAL segment to an archive command, and how a restore replays those segments to a chosen moment. WAL-G fills that role through the archive settings in postgresql.conf and a restore command that fetches segments back. Your RPO depends on how quickly completed WAL segments reach the bucket, so the archive path, its failure alerts and the time to notice a stalled archive all need to be designed and tested, not assumed.

WAL-G fits best when object storage is the intended repository, the team wants a single tool with few moving parts, and it can accept the operational model of pushing directly to a bucket. It is a weaker match when the team needs a dedicated backup server or a particular repository layout that another tool already provides. Compare it with pgBackRest and Barman on the features your recovery plan depends on, and check the built-in option, incremental backups with pg_basebackup and pg_combinebackup from PostgreSQL 17, before committing. Ask the implementation partner or your own team to document which tool owns each step of backup, retention and restore so that no one discovers the gap during an incident.

How base backups and WAL reach object storage and come back on restore

The diagram starts at the primary, where PostgreSQL hands each completed WAL segment to archive_command, which calls WAL-G. WAL-G pushes base backups and WAL files to the object store, and that is the hand-off to check first: confirm each WAL push succeeds, since a failed archive stops recycling and fills the primary's disk. On restore, a separate host runs backup-fetch to pull the base backup and then replays archived WAL up to the target time. The trust boundary around the object store credentials marks where the write and read keys live and who can reach them.

Write and read paths to object storage, with credentials inside the trust boundary.

Which WAL-G configuration options fit which environment

WAL-G pushes base backups and WAL segments to object storage, and the backend you pick decides which credentials, endpoints and regional controls you manage. S3-compatible storage is the most common choice and also covers self-hosted object stores such as Ceph, provided the endpoint and path-style settings match what the store expects. GCS and Azure Blob Storage follow the same pattern with their own authentication model. Choose the backend that already sits under your data residency, access logging and backup accounts, because moving backups later means re-validating the whole chain.

  • S3 or S3-compatible: Fits organizations with existing AWS accounts or an on-premises object store. Confirm endpoint, region and addressing style for your version.
  • GCS: Fits teams already running on Google Cloud, with service account access managed through IAM.
  • Azure Blob Storage: Fits Azure-centric estates, where storage account keys or managed identity must be set up deliberately.
  • Cross-account or cross-region copies: Add cost and transfer time, but reduce dependence on one account or region.
  • Air-gapped networks: Usually need an internal S3-compatible store, since public cloud endpoints are unreachable.

Before you commit, confirm the exact storage configuration keys in the WAL-G documentation for your version, and verify the backend with a test push and a test fetch.

Setting up WAL-G with archive_command and a first base backup

This sequence takes a primary from no backups to a working WAL archive and a base backup in object storage, with a check at each step so the team knows the chain is sound before relying on it. It also leaves a restore host ready to fetch from the same repository.

  1. Provision the bucket and least-privilege credentials

    The platform or storage team creates a dedicated bucket in S3, GCS or Azure Blob Storage for the WAL-G repository, then creates a service identity that can only write, list and read objects under that bucket or prefix. Keep the credentials separate from any application account and record where they will be stored, such as your secrets manager. Confirm the bucket's region, encryption and access logging settings against your own policy, since these are not set by WAL-G. Done means the identity can upload and list a test object under the prefix and is denied access to other buckets.

  2. Install WAL-G on the primary and restore hosts

    The database administrator installs the WAL-G binary on the primary server and on each host that will perform restores, using a build that matches your operating system and object storage provider. Pin the version and record it in your change log so every host runs the same release. Check the installed version and confirm the binary can reach the bucket with a list command. Confirm the exact installation method and current release with the WAL-G project documentation before you deploy, since this page does not list versions.

  3. Configure storage variables for WAL-G

    Set the repository location and credentials as environment variables that the PostgreSQL service account can read, for example the storage prefix and the provider-specific access settings used by WAL-G. Keep these in a root-owned file with restricted permissions, not in postgresql.conf or shell history. Run a list or status command as the postgres user to confirm WAL-G reads the variables and reaches the repository. Done means the command returns without an authentication or permission error.

  4. Set archive_mode and archive_command

    The DBA sets archive_mode to on and points archive_command at wal-g wal-push, passing the WAL file path, in postgresql.conf. Changing archive_mode requires a server restart, so schedule the change in a maintenance window or a period your recovery objectives allow. Once the server restarts, confirm the settings with SHOW archive_mode and SHOW archive_command. Done means both values match what you configured and the server runs without a configuration error in the log.

  5. Take the first base backup

    The DBA runs wal-g backup-push against the data directory as the postgres user, which creates the first full base backup in the repository. Run it at a time when the extra I/O and network use will not hurt your workload, and set the upload concurrency and rate limits you plan to keep in production before the run. When the command finishes, list the backups and confirm the new entry shows the expected start time and size. Done means the backup appears in the list with a usable name that you can cite in a restore test.

  6. Verify WAL segments land in the bucket

    Force a WAL switch on the primary with pg_switch_wal(), then check the archive status in pg_stat_archiver to confirm archived_count increases and failed_count does not. Open the bucket and confirm new WAL segment objects appear under the WAL prefix with recent timestamps. Also review the PostgreSQL log for archive_command errors. Done means several consecutive WAL segments are archived with no failures recorded, which shows the chain is continuous from the base backup forward.

  7. Fetch the backup on a restore host to confirm access

    On a separate restore host with no running PostgreSQL service, the administrator runs wal-g backup-list with the same configuration to confirm the host sees the repository. Then run backup-fetch into an empty scratch directory to confirm the base backup downloads cleanly. This test does not replace a full restore drill, which is covered separately, but it proves the credentials, storage settings and WAL-G version work from the host that will need them during an incident. Done means the backup lists correctly and the fetch completes without errors.

How WAL-G compares with pgBackRest in daily operations

WAL-G and pgBackRest both take physical base backups and archive WAL for point-in-time recovery, so the decision usually comes down to daily operations rather than basic capability. The cards below cover the differences that shape day-two work, and the right choice depends on your storage, restore and operating practices. Confirm each point against the current release of each tool before you commit.

Configuration and repository model

WAL-G is configured mainly through environment variables or a config file and writes directly to an object store such as S3, GCS or Azure, with no dedicated repository host. pgBackRest typically uses a repository it manages, which can sit on a dedicated backup server, a local disk or object storage. Check which model fits your network layout, how many clusters share one repository, and where credentials are stored.

Continuous archiving docs

Delta and incremental behavior

Both tools can reduce the data copied after a full backup, but they do it differently. WAL-G's delta backups depend on page-level tracking against a previous backup, while pgBackRest offers differential and incremental backup types with its own chain rules. Ask each vendor how a backup chain is built, how long chains stay dependent on one another, and how a broken link is detected before you plan a schedule.

Restore workflow

WAL-G restores with a backup-fetch step that pulls a base backup from the object store into a data directory, after which WAL replay is driven by a restore_command. pgBackRest restores through its own restore command that can target a point in time or a named restore point and can run in parallel. Time a restore on your largest cluster in a test environment, because the restore path decides how the RTO target is met.

Retention and expiry management

Retention in WAL-G is usually handled by a delete command that removes backups and WAL older than a chosen point, and it must be run carefully so it does not remove WAL still needed by retained base backups. pgBackRest manages retention through configured full and differential counts and expiry rules applied by its own tooling. Confirm how each tool handles retention when a backup is marked in progress or fails, and test expiry against a copy of the repository first.

Concurrency and rate controls

Upload and download concurrency, and limits on bandwidth or disk pressure during backups, affect both backup windows and production load. Both tools expose settings for parallel workers and throughput, but the names, defaults and interaction with your object store's request limits differ. Measure backup impact on the primary during a peak period and set limits before the first scheduled run.

Operator familiarity and support model

pgBackRest has a long history in many PostgreSQL shops and a broad base of operator documentation, while WAL-G is often chosen by teams already standardized on cloud object storage and container tooling. Check which tool your on-call engineers already know, who maintains each tool in your region, and how security fixes reach you. Your own runbooks and the people who will run restores at 3 a.m. should weigh heavily in the decision.

How backup-fetch and WAL replay restore to a target time

A WAL-G restore follows a fixed sequence: choose a base backup, fetch it into an empty data directory with wal-g backup-fetch, set the recovery target, replay archived WAL from the bucket, and then promote the server. The base backup is chosen by name or by the latest entry that precedes the target time, so the operator needs the backup list before touching the data directory. The recovery target is set in the PostgreSQL configuration (recovery_target_time, or a named restore point or transaction ID if the incident calls for one), and a restore_command that calls wal-g wal-fetch tells PostgreSQL how to pull each archived segment back from the bucket. The server then replays WAL up to the target and stops there. Promotion should be a deliberate step after you have checked the data, not an automatic one. Confirm the exact recovery parameter names and their behavior for your PostgreSQL major version in the continuous archiving documentation before writing the runbook.

The restore needs three things in place before the clock starts. First, enough free disk for the fetched base backup plus the WAL replayed on top of it, plus headroom for the restored server to run. Ask your storage team to confirm this against the size of your latest backup rather than the size of the live database, since compression and delta chains change the numbers. Second, the restore host must run the same PostgreSQL major version as the one that wrote the backup, and the WAL-G build must match the one that archived it. Third, the host needs read credentials to the exact bucket, prefix and region, separate from the write credentials the backup job uses. A restore that waits on a credential request or a missing IAM policy is a common cause of a slow recovery.

Restore time is the number that matters most for a recovery time objective, and it is the number teams most often assume. Download throughput, decompression, the volume of WAL between the base backup and the target, and the speed of the replay itself all vary with the database and the network path to the bucket. Run a timed restore into an isolated host on a schedule, record the elapsed time for each stage, and compare the total to your recovery time objective. Keep the timings with the runbook so the next person knows whether the figure is current. The companion page on verifying backups and testing restores covers how to build that drill.

Protecting WAL-G credentials, encryption and backup copies

A WAL-G setup is only as safe as the credentials that write to and delete from its bucket. The cards below cover how to scope those credentials, separate duties between accounts, encrypt data in transit and at rest, and keep a copy the primary cannot erase.

Scope write credentials to the backup path

The host running wal-push and backup-push needs write access to the WAL and backup prefixes in the object store, and little else. Grant put and list rights on that prefix only, with no bucket-wide admin rights. Check that the same credential cannot read other clients' prefixes or change bucket policy. Keep the WAL-G configuration, including the storage prefix, under version control so the scope is reviewable.

Use read-only credentials for restores

backup-fetch and wal-fetch only read from the repository, so restore hosts should hold a read-only credential. Keep this separate from the write credential, so a restore host cannot be used to alter or delete backups. Restore drills are a good moment to confirm the read-only credential actually works, because a restore that fails on a missing permission during an incident costs time you cannot recover.

Separate backup and administrative accounts

Keep the account that runs backups apart from the account used to manage the bucket, its lifecycle rules and its versioning settings. Administrators should use named, individually audited identities with multi-factor authentication, and should not share the backup job's key. Ask your team who can change retention or delete objects, and whether that action is logged outside the account it affects.

Encrypt in transit and at rest

Confirm that WAL-G connects to the object store over TLS and that the endpoint certificate is validated, including for on-premises S3-compatible storage. WAL-G can also encrypt its own uploads, and its documentation describes the key options for the chosen storage backend. Store encryption keys separately from the bucket they protect, record who can read them, and test that a restore works with the key held by your recovery process.

Keep a copy the primary cannot erase

A compromised primary holds the same credentials WAL-G uses, so an attacker or a faulty script on that host could delete base backups and WAL segments along with the live data. Mitigate this with object versioning or object lock on the bucket, a separate account or project for the repository, and a retention period that outlasts detection time. The offsite and immutable backups topic covers these designs in more depth.

Verify the copy regularly

A backup repository with a sound access model still needs checks that it remains complete. Schedule a periodic backup-fetch into a scratch host, confirm the replay of WAL to a target point, and compare the list of backups against the retention you intended. Record the results with timestamps, so you can show an auditor or a recovery lead what was tested and when.

Questions buyers ask before hiring help with WAL-G

What drives the cost of a WAL-G backup engagement?

The cost follows the written scope, and the main drivers are the number of PostgreSQL environments, the storage and network path to your bucket, the number of restore targets, and how much restore testing you want evidence for. Each production cluster, standby and staging copy adds configuration, scheduling and verification work. A cross-region or private network path to S3, GCS or Azure Blob Storage adds design and access work. Ask for a quote that lists each environment, each restore target and the test cycles separately, so you can see which items recur after handover and which are one-time setup.

How long does a WAL-G backup project take?

No duration is fixed here because it depends on how many clusters you have, how your object storage and credentials are already set up, and how many restores you want proven. Most engagements are fixed-scope, so scope, deliverables and timelines are agreed in writing before any work starts. Ask the provider to state the phases in that document: design, build in a non-production environment, first full backup and WAL archiving confirmed, restore test, and handover. Also ask which steps depend on your change windows or on approvals from your storage or security teams.

What do we need to provide before the work starts?

You need to supply access and a place to test, not just a bucket name. Typical requirements are a bucket or container in S3, GCS or Azure with a dedicated backup identity that has only the permissions WAL-G needs, a PostgreSQL server or staging cluster for trial restores, network routes from the database hosts to the storage endpoint, and named people who can approve change windows. A separate restore environment is important, because a restore test on the production host can hide problems such as missing environment variables or wrong credentials. Confirm these with your storage and security teams early.

Can our own team run WAL-G without outside help?

Yes, if your team already runs PostgreSQL and object storage and can own the scheduled jobs, alerts and restore drills. WAL-G is a single tool, but the work sits in the surrounding parts: WAL archive settings in postgresql.conf, the archive_command path, retention rules, credential rotation and rehearsed restores with backup-fetch. Teams that have not restored from a backup under time pressure often find the gaps during the first real incident. An outside partner is most useful for the design decisions, the first end-to-end restore and training, after which your team takes over the runbook.

What does a WAL-G engagement cost to keep running after handover?

Recurring costs are your own: object storage capacity and requests, egress if restores cross networks, compute for scheduled restore tests, and staff time for monitoring. A support or maintenance retainer is optional and covers things like upgrading WAL-G, reviewing retention, and rerunning restore tests after PostgreSQL minor updates. Check your storage provider's pricing pages for the storage and transfer figures, because no figure for those is supplied here. Ask the provider which items in the quote are one-time and which recur, and whether a retainer is needed at all.

How does WAL-G compare with pgBackRest for operations?

WAL-G is a single binary that pushes base backups and WAL to object storage, and its restore path is backup-fetch plus a recovery configuration. pgBackRest is a more feature-rich tool with its own repository model, and it is often chosen when teams want that layout. The operational differences show up in how you configure repositories, schedule full and delta backups, set rate and concurrency limits, and verify restores. Compare both on the same test cluster with your real retention and restore-time targets before choosing. The sibling page on pgBackRest covers its setup in more detail.

What should we check to know the backups will actually restore?

Ask for evidence of a completed restore, not only a successful backup job. Check that WAL archiving is confirmed, that a full restore runs on a separate host with backup-fetch, that the recovered cluster reaches the target time you chose, and that the measured restore time is recorded against your recovery time objective. Also confirm that delta backups restore correctly, that retention keeps enough base backups to cover your recovery point needs, and that failed uploads raise alerts. Ask the provider to deliver the restore test steps as a runbook your team can repeat.

Why a WAL-G setup is not finished until a restore is tested

A WAL-G archive that is receiving base backups and WAL segments is not proof of recovery. It shows that uploads succeed, not that the data can be rebuilt into a working database at the moment you need it. The only way to establish recovery is to run a restore on purpose, and to treat a failed or slow restore as a defect in the backup setup rather than as a surprise for the incident team. Teams should write this drill into the runbook before go-live and repeat it on a schedule.

A practical drill runs on a scratch host that has no connection to production clients. Fetch the most recent base backup with wal-g backup-fetch into an empty data directory, configure restore_command so WAL-G pulls archived segments with wal-g wal-fetch, and set recovery_target_time to a timestamp chosen before a known bad change. Start the server, let it replay to that target, then promote it. Run the application's own checks against the restored database, such as row counts on key tables, reconciliation queries and a sample of business transactions, and keep the output. Record the elapsed time from the first fetch to the first successful application check and compare it with the recovery time target agreed for the service. Rehearsing the same steps by hand also confirms that the credentials, bucket permissions and WALG_ environment settings used during the drill match what the runbook says.

The general method for proving backups, including checksum validation, scheduled drills and the evidence kept for auditors, is covered in the verification and restore testing guidance for point-in-time recovery. Confirm with your own risk owner how often drills must run, who signs off the results and how long records are kept. Each drill that misses the target should lead to a documented change, such as a faster fetch path, a larger scratch host or a shorter WAL replay window, followed by a retest.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.