Shuttle 2.0: verified PostgreSQL backups shipped over SSH

Shuttle 2.0: verified PostgreSQL backups shipped over SSH


Npm package
PostgreSQL Node.js TypeScript Docker Backup SSH
Last updated on

Brief

Shuttle is an open source tool that backs up PostgreSQL databases on a schedule, ships the backups to another server over SSH, verifies every transfer, prunes old backups and emails a report after every run. It installs with one npm command, or runs in a Docker image that already bundles the PostgreSQL client.

Version 2.0 is a deep rework. It fixes flaws in v1 that could make a backup look fine when it was not.

Table of contents

Why Shuttle

A backup that stays on the same machine as the database does not protect you from much: if the server goes down, the backup goes with it. It has to be sent somewhere else, regularly, and you need to know it arrived intact.

I wanted a simple tool to do that for my production projects: one config file, a daemon, and an email telling me whether everything went well. Shuttle does exactly that, without depending on a cloud service.

What changed in v2

Shuttle v1 versus v2: verified transfers, pinned SSH host key, fixed remote retention, email reports

While reworking the code for v2, I realized v1 had several serious problems. It looked like it worked, but some guarantees were not actually kept:

  • Transfers were not verified. An upload cut off halfway could be recorded as a successful backup. In v2, every file is uploaded under a temporary name, its size is compared with the local file, and it is only renamed once the size matches.
  • Any server was accepted. v1 did not check the destination server’s SSH key, so anyone able to intercept the connection could receive the production dump. In v2, the server is pinned with a known_hosts file or a SHA256 fingerprint.
  • Remote retention deleted nothing. In v2, keepLast really applies, locally and on the server. Files Shuttle cannot read or date are left alone: keeping one file too many beats losing a good backup.
  • The -c option was ignored. v1 always loaded ./shuttle.yml, whatever was passed. That is fixed, and the config is now validated at startup with a readable error.
  • Node 18 was end-of-life and pinned a vulnerable node-cron. v2 requires Node 22.12 or newer, and the Docker image runs as a non-root user.

v2 also adds an email report after every run, through SendGrid or Resend: the source database, the file shipped, the duration, or the error when something failed.

How it works

Shuttle's four stages: configure, dump, ship and verify, report
  1. Configure. One YAML file describes the database, the destination server, the schedule, retention and who gets the report. It is validated before anything runs.
  2. Dump. On each cron tick, pg_dump exports the whole database or a list of tables. The dump is gzip-compressed as a stream, so memory stays flat whatever the database size.
  3. Ship and verify. The file goes over SFTP under a temporary name, its size is checked, then it is renamed. Old backups are only pruned after that check.
  4. Report. An email goes out with the result, either always, only on success, or only on failure.

What Shuttle guarantees

  • Host key verification: the destination server is pinned.
  • Atomic, verified transfers: a truncated transfer never becomes a backup.
  • Overlap-safe scheduling: a dump slower than its interval is never started twice, and shutdown waits for the backup in flight.
  • Defensive retention: keepLast locally and remotely, without touching unknown files.
  • Bounded memory: a 200 GB database needs the same RAM as a 200 MB one.
  • Full or table dumps, in custom or plain format, compressed by default.
  • Secrets out of the file: values such as ${DATABASE_URL} are read from the environment.

Installation

As a CLI, with Node 22.12+ and a pg_dump at least as recent as the server:

npm install -g @claquettes/shuttle
shuttle init
shuttle validate -c shuttle.yml
shuttle daemon -c shuttle.yml

Or with Docker, whose image already bundles a PostgreSQL 18 client:

services:
  shuttle:
    image: claquettes/shuttle:latest
    volumes:
      - ./shuttle.yml:/config/shuttle.yml:ro
      - ./ssh_key:/config/ssh_key:ro
    command: shuttle daemon -c /config/shuttle.yml

Tests and CI

For a backup tool, the guarantees had to be tested, not just promised. Every push goes through GitHub Actions:

  • lint, formatting check and strict TypeScript build;
  • unit tests on Node 22 and 24: CLI, email, SSH security, scheduler;
  • end-to-end tests on PostgreSQL 14, 15, 16 and 17 against a real SFTP server: dump, verified transfer, retention, then restore;
  • a memory test on about 200 MB of data, to make sure compression stays memory-bounded;
  • a Docker image test.

Releases are automated from a git tag. The workflow checks that the tag matches the package.json version, runs the whole suite again, publishes to npm with npm provenance (the package is linked to the commit and workflow that built it), then pushes the image to Docker Hub and GitHub Container Registry.

The repository also ships a documentation-agent.md file: a complete reference (config schema, deployment, checks, troubleshooting) written to be handed directly to a coding agent integrating Shuttle into a project.

Upgrading from v1

v1 config files work as they are. Three things to watch:

  • v2 requires Node 22.12 or newer, which changes nothing if you use the Docker image;
  • since remote retention finally works, the first run of each job will clean up: check that keepLast matches what you want to keep;
  • since -c is now honoured, check that the right file is loaded.

Adding known_hosts or host_fingerprint, and an email report, is also recommended.

© 2026 Mathieu Ponton | Co-Founder & ingénieur logiciel @ Apogée Consult | Lyon, France