# vasyakrg/pgdump-s3 architecture

> Architecture diagram of the GitHub repository vasyakrg/pgdump-s3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vasyakrg/pgdump-s3
- Repository: https://github.com/vasyakrg/pgdump-s3

## Overview

This repository packages a PostgreSQL backup and restore script. The main workflow selects databases, creates dumps, stores them locally or in S3, and applies retention; scheduled runs use cron. Restore reads selected backups, restores databases, and can run post-restore SQL. The README also documents role backups, multiple dump formats, compression, and success healthchecks. The tree shows `backup.sh` and SQL directories, but no source excerpts were provided, so relationships below rely on README statements rather than inspected implementation; internal call details remain unverified.

Main entry points: [`backup.sh`](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh) (Backup and restore runner), [`post-restore`](https://github.com/vasyakrg/pgdump-s3/tree/main/post-restore) (Post-restore SQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_backup["Backup"]
  node_backup_run["Backup and restore runner<br/>[backup.sh]"]
  node_dump_creation["Dump selection and formats<br/>[backup.sh]"]
  node_role_dump["Role dump<br/>[backup.sh]"]
end

subgraph group_storage["Storage"]
  node_storage_backend["Local or S3 storage<br/>[backup.sh]"]
  node_retention["Backup rotation<br/>[backup.sh]"]
end

subgraph group_restore["Restore"]
  node_restore_selection["Restore selection<br/>[backup.sh]"]
  node_database_restore["Database restore<br/>[backup.sh]"]
  node_post_restore["Post-restore SQL"]
end

subgraph group_operations["Operations"]
  node_healthchecks["Healthchecks service"]
end

node_operator(("Operator"))
node_scheduler(("Cron scheduler"))
node_postgres[("PostgreSQL")]

node_operator -->|"starts manually"| node_backup_run
node_scheduler -->|"starts scheduled"| node_backup_run
node_backup_run -->|"selects and dumps"| node_dump_creation
node_dump_creation -->|"reads databases"| node_postgres
node_backup_run -.->|"optionally dumps roles"| node_role_dump
node_backup_run -->|"stores backups"| node_storage_backend
node_backup_run -->|"rotates backups"| node_retention
node_operator -->|"selects restore"| node_restore_selection
node_restore_selection -->|"reads backups"| node_storage_backend
node_restore_selection -->|"chooses databases"| node_database_restore
node_database_restore -->|"restores databases"| node_postgres
node_database_restore -.->|"runs scripts"| node_post_restore
node_backup_run -.->|"sends success check"| node_healthchecks

click node_backup_run "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_dump_creation "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_role_dump "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_storage_backend "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_retention "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_restore_selection "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_database_restore "https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh"
click node_post_restore "https://github.com/vasyakrg/pgdump-s3/tree/main/post-restore"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_backup_run,node_dump_creation,node_role_dump toneBlue
class node_storage_backend,node_retention,node_postgres toneAmber
class node_restore_selection,node_database_restore,node_post_restore toneMint
class node_healthchecks,node_scheduler toneRose
class node_operator toneIndigo
```

## Components

### Backup

- [Backup and restore runner](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`
- [Dump selection and formats](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`
- [Role dump](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`

### Storage

- [Local or S3 storage](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`
- [Backup rotation](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`

### Restore

- [Restore selection](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`
- [Database restore](https://github.com/vasyakrg/pgdump-s3/blob/main/backup.sh): `backup.sh`
- [Post-restore SQL](https://github.com/vasyakrg/pgdump-s3/tree/main/post-restore): `post-restore`

### Operations

- **Healthchecks service**

### Other components

- **Operator**
- **Cron scheduler**
- **PostgreSQL**

## Connections

- Operator → Backup and restore runner: starts manually (evidence: `README.md`)
- Cron scheduler → Backup and restore runner: starts scheduled (evidence: `README.md`)
- Backup and restore runner → Dump selection and formats: selects and dumps (evidence: `README.md`)
- Dump selection and formats → PostgreSQL: reads databases (evidence: `README.md`)
- Backup and restore runner → Role dump: optionally dumps roles (evidence: `README.md`)
- Backup and restore runner → Local or S3 storage: stores backups (evidence: `README.md`)
- Backup and restore runner → Backup rotation: rotates backups (evidence: `README.md`)
- Operator → Restore selection: selects restore (evidence: `README.md`)
- Restore selection → Local or S3 storage: reads backups (evidence: `README.md`)
- Restore selection → Database restore: chooses databases (evidence: `README.md`)
- Database restore → PostgreSQL: restores databases (evidence: `README.md`)
- Database restore → Post-restore SQL: runs scripts (evidence: `README.md`)
- Backup and restore runner → Healthchecks service: sends success check (evidence: `README.md`)
