How chabid19/postgresql-backup works
This is a Node.js utility for scheduled PostgreSQL backups, gzip compression, retention cleanup, and restoration. The principal workflow is systemd-triggered execution through the CLI, which loads and validates configuration, dumps configured databases (optionally roles) into timestamped files, then removes expired backups. Manual commands also expose backup-only, cleanup-only, restore, and dry-run modes. The source excerpts show the runtime calls; systemd scheduling is documented in the README, so its unit relationship is documented rather than inferred from unsampled unit contents.
Main entry points: index.js CLI Dispatcher · backup.js Backup & Gzip · restore.js Restore · logger.js Logger
Components 14
Execution
- CLI Dispatcher
src/index.js
Configuration
- Config Loader
src/config.js - Env File Loader
src/env.js - Logger
src/logger.js
Backup Operations
- Backup & Gzip
src/backup.js - Retention Cleanup
src/cleanup.js - Restore
src/restore.js - Backup Files
PostgreSQL & Scheduling
- Systemd Timer
systemd/postgresql-backup.timer - Systemd Service
systemd/postgresql-backup.service - pg_dump / pg_dumpall
- psql
- PostgreSQL
Other components
- Operator
Connections 21
- Operator → CLI Dispatcher: invokes
README.md - Systemd Timer → Systemd Service: triggers
README.md - Systemd Service → CLI Dispatcher: runs
README.md - CLI Dispatcher → Config Loader: loads
src/index.js - Config Loader → Env File Loader: loads variables
src/config.js - CLI Dispatcher → Logger: creates
src/index.js - CLI Dispatcher → Backup & Gzip: dispatches
src/index.js - CLI Dispatcher → Retention Cleanup: dispatches
src/index.js - CLI Dispatcher → Restore: dispatches
src/index.js - Backup & Gzip → Logger: formats timestamp
src/backup.js - Backup & Gzip → pg_dump / pg_dumpall: runs dumps
src/backup.js - Backup & Gzip → PostgreSQL: reads database
README.md - Backup & Gzip → Backup Files: writes gzip files
src/backup.js - Retention Cleanup → Backup Files: reads and deletes
src/cleanup.js - Retention Cleanup → Logger: reports
src/cleanup.js - Restore → Backup Files: reads dump
src/restore.js - Restore → psql: streams restore
src/restore.js - Restore → Backup & Gzip: uses PostgreSQL environment
src/restore.js - Restore → Logger: reports
src/restore.js - pg_dump / pg_dumpall → PostgreSQL: queries
README.md - psql → PostgreSQL: restores into
README.md