DEV Community

Cover image for wal-e Postgres Backups - Building SaaS #32
Matt Layman
Matt Layman

Posted on • Originally published at mattlayman.com

4 2

wal-e Postgres Backups - Building SaaS #32

In this episode, we worked on Postgres database backups and modified the backup tool, wal-e, to use the Shiv app format.

wal-e is Postgres database backup tool that works by managing the Write-Ahead Log (WAL) that a Postgres database produces. The WAL is the log of recent changes that happened in the database. If you have access to a full WAL, then you can conceivably reproduce a Postgres database's data.

When I switched the deployment to use a Shiv app, we now have to remove every use of the existing virtual environment in the system. The wal-e executable is installed in the bin directory of the virtual environment so we need another way to access it.

The way that the Shiv app can execute other binaries is with the [SHIV_ENTRY_POINT](https://shiv.readthedocs.io/en/latest/#shiv-entry-point) environment variable. Using the setuptools-style link of wal_e.cmd:main, we can run the wal-e executable that is available to the Shiv app. Because I already use the envdir command, we only had to make two changes:

  1. Replace {{ venv_path }}/bin/wal-e with /srv/apps/conductor.pyz.
  2. Add a SHIV_ENTRY_POINT file to /etc/wal-e/env with the appropriate setuptools-style value.

Once we made the changes, I deployed things to the staging site with Ansible. From there, we verified that the cron entry was changes with:

$ sudo su -  # change to root
$ su - postgres  # change to postgres account
$ crontab -l  # list cron entries

With the wal-e updates in place, nothing used the Python virtual environment so we could finally delete it!

In the next stream, we're going to begin the process of removing the Git clone to complete the process of simplifying deployment.

This article first appeared on mattlayman.com.

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (0)

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay