Skip to main content

Module backup

Module backup 

Source
Expand description

kasl-server backup and restore: the installation’s data as one file.

An operator running this on their own hardware owns the consequences of losing it, so taking a copy has to be something they can do without knowing PostgreSQL. pg_dump is the better tool for someone who already has a backup regime; this is for everyone else, and it does two things pg_dump cannot:

  • It knows the schema version. A dump carries the migration it was taken at, and a restore refuses a file from a newer server rather than loading rows into tables whose columns have since changed. The failure mode being avoided is not an error - it is a restore that appears to work and quietly drops what the older schema has no place for.
  • It is the same binary. No postgres-client package on the host, no version skew between a client and the server it dumps.

JSON Lines rather than SQL: each line is a table’s worth of rows, so a file can be read by anything, checked by eye, and streamed without holding the installation in memory.

Structs§

Header
What the file says about itself, on its first line.
Summary
What a backup or restore moved.

Constants§

SETTINGS
Tables the restore replaces wholesale but never empties from the file.
TABLES
Tables in the order they must be written and loaded.

Functions§

dump
Writes the whole installation to out.
load
Reads a backup into an empty installation.