Dump and Restore Procedures Guide
Table of Contents
- Overview
- Dump Operations
- Restore Operations
- In-Memory Databases
- Scheduling Dumps
- Best Practices
- Troubleshooting
Overview
heliosdb-lite dump writes a database to a compressed dump file, and
heliosdb-lite restore loads a dump file into a database. Both work in two modes:
| Mode | Dump | Restore |
|---|---|---|
| Embedded | --data-dir reads a data directory directly | --target writes a new data directory |
| Server | --connection runs BACKUP DATABASE on a running server; the file is written on the server’s filesystem | --connection runs RESTORE DATABASE on a running server; the file must be readable by the server |
Dump files are compressed (Zstandard by default) but not encrypted. See the CLI Reference for every flag.
Dump Operations
Basic Dump
# Full dump of a data directory (stop the server first for a consistent copy)heliosdb-lite dump --data-dir /var/lib/heliosdb --output backup.heliodump
# Choose the compression: zstd (default), gzip, brotli or noneheliosdb-lite dump --data-dir /var/lib/heliosdb --output backup.heliodump --compression gzip
# Selected tables only (embedded mode)heliosdb-lite dump --data-dir /var/lib/heliosdb --output users.heliodump --tables users,sessions
# Progress outputheliosdb-lite dump --data-dir /var/lib/heliosdb --output backup.heliodump --verboseDump Sizes and Throughput
Figures from internal tests (HeliosDB Lite dump and restore of a 1 GB database, Zstandard vs no compression); reproduce on your own hardware and data:
| Compression | Typical ratio | Speed |
|---|---|---|
none | 1.0x | Fastest |
zstd (default) | 3.0-5.0x | Medium |
| Operation | Size | Time | Throughput |
|---|---|---|---|
| Dump (no compression) | 1 GB | 15s | 66 MB/s |
| Dump (zstd) | 1 GB → 300 MB | 35s | 28 MB/s |
| Restore (no compression) | 1 GB | 25s | 40 MB/s |
| Restore (zstd) | 300 MB → 1 GB | 40s | 25 MB/s |
An uncompressed dump is about 90% of the in-memory size, a Zstandard dump 20-40% of the uncompressed one, and a daily incremental dump 5-15% of a full dump.
Incremental Dumps
# First dump (full)heliosdb-lite dump --data-dir /var/lib/heliosdb --output base.heliodump
# Later: append the changes since the previous dumpheliosdb-lite dump --data-dir /var/lib/heliosdb --output base.heliodump --appendDumping a Running Server
heliosdb-lite dump \ --connection "host=db.example.com port=5432 user=postgres" \ --tls --tls-ca ca.crt \ --output backup.heliodumpThe server writes the dump on its own filesystem and reports the dump ID; copy the file
from the server host. --tables is not supported in server mode.
The same operation is available in SQL to a role with maintenance privileges:
BACKUP DATABASE TO '/backups/full.hldb';BACKUP DATABASE INCREMENTAL TO '/backups/inc.hldb';Server-mode backups contain table definitions and rows. Recreate indexes, roles, grants and row-level security policies after restoring one, and pause writes while it runs for a consistent copy.
Restore Operations
Basic Restore
# Restore into a new data directory, checking the dump firstheliosdb-lite restore --input backup.heliodump --target /var/lib/heliosdb-restored --verify
# Restore selected tablesheliosdb-lite restore --input backup.heliodump --target ./restored --tables users,sessionsWithout --target, the restore goes to ./heliosdb-data-restored. Start a server on
the restored directory with heliosdb-lite start --data-dir <target>.
Restoring into a Running Server
heliosdb-lite restore \ --connection "host=db.example.com port=5432 user=postgres" \ --tls --tls-ca ca.crt \ --input /backups/backup.heliodumpThe path must be readable by the server process.
In-Memory Databases
In-memory servers and REPL sessions can write a dump when they shut down:
# Serverexport HELIOSDB_JWT_SECRET="$(openssl rand -hex 32)"heliosdb-lite start --memory --dump-on-shutdown
# REPLheliosdb-lite repl --memory --dump-on-shutdown --dump-file ./session.heliodumpScheduling Dumps
The --dump-schedule flag of heliosdb-lite start is planned and not yet acted on.
Schedule dumps with cron or a systemd timer:
# crontab: nightly dump at 02:00 from a running server0 2 * * * heliosdb-lite dump --connection "host=127.0.0.1 port=5432 user=postgres" --output /backups/nightly.heliodumpBest Practices
- Consistency: dump a stopped data directory, or pause writes during the dump.
- Encryption: dump files are not encrypted; encrypt them before they leave the host
(for example
gpg --symmetric --cipher-algo AES256 backup.heliodump). - Off-host copies: keep copies on another machine or in object storage.
- Test restores: restore into a scratch directory regularly and compare row counts with the source.
- Verify after restore: check tables, roles, grants and row-level security policies before you rely on a restored database.
Troubleshooting
”Either —data-dir or —connection must be specified”
Pass the data directory to dump, or a connection string for a running server.
”—tables filtering is not supported in server mode yet”
Use embedded mode (--data-dir) for per-table dumps.
Restore Fails with a Checksum or Format Error
Run heliosdb-lite restore --verify on the file. If the file is damaged, restore from
an older copy. Restore dumps with a release at least as new as the one that wrote them.
See Also
- In-Memory Mode Guide - In-memory database operations
- CLI Reference - Complete command reference
- Configuration reference - Configuration settings