# leistnerm/configbackup architecture

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

- Interactive diagram: https://gitdiagram.com/leistnerm/configbackup
- Repository: https://github.com/leistnerm/configbackup

## Overview

ConfigBackup is a one-shot, configuration-driven utility for capturing files and generated artifacts, versioning changes, and maintaining filesystem or Git history. Its main workflow is: an operator starts a run, ConfigBackup loads and validates YAML, runs configured preparation tasks, collects matching sources, then stores changed snapshots and applies retention while recording state and manifests. Optional PostgreSQL, SQL Server, and guest-system collectors produce current-state trees for that workflow to archive. Internal stages are inferred from the documented behavior and sampled excerpts; unsampled subsystem wiring is represented only where the README documents it.

Main entry points: [`configbackup.py`](https://github.com/leistnerm/configbackup/blob/main/configbackup.py) (Task execution), [`collectors/postgresql/collect_postgresql.py`](https://github.com/leistnerm/configbackup/blob/main/collectors/postgresql/collect_postgresql.py) (PostgreSQL collector), [`collectors/sqlserver/Collect-SqlServerConfiguration.ps1`](https://github.com/leistnerm/configbackup/blob/main/collectors/sqlserver/Collect-SqlServerConfiguration.ps1) (SQL Server collector), [`collectors/system/collect_system.py`](https://github.com/leistnerm/configbackup/blob/main/collectors/system/collect_system.py) (Guest-system collector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_run["Run orchestration"]
  node_runner["Run entry and CLI<br/>[configbackup.py]"]
  node_loader["Config loading<br/>[configbackup.py]"]
  node_taskexec["Task execution<br/>[configbackup.py]"]
end

subgraph group_collect["Capture and collectors"]
  node_pg["PostgreSQL collector"]
  node_sql["SQL Server collector"]
  node_system["Guest-system collector<br/>[collect_system.py]"]
  node_staging["Generated artifact trees"]
end

subgraph group_lifecycle["Archive lifecycle"]
  node_discovery["Source discovery<br/>[configbackup.py]"]
  node_versioning["Change detection and versions<br/>[configbackup.py]"]
  node_retention["Retention and deletion<br/>[configbackup.py]"]
  node_state[("Run state and manifests<br/>[configbackup.py]")]
end

subgraph group_storage["Storage backends"]
  node_filesystem[("Filesystem archive<br/>[configbackup.py]")]
  node_git[("Git history<br/>[configbackup.py]")]
end

node_operator(("Operator or scheduler"))
node_config["YAML configuration"]
node_source["Files and directories"]
node_pgtools["PostgreSQL client tools"]
node_sqltools["SqlPackage and dbatools"]
node_host["Host OS and commands"]
node_remote[("Git remote")]
node_github["GitHub PR service"]

node_operator -->|"starts run"| node_runner
node_config -->|"provides settings"| node_loader
node_runner -->|"loads configuration"| node_loader
node_loader -->|"configures tasks"| node_taskexec
node_taskexec -.->|"runs collector"| node_pg
node_taskexec -.->|"runs collector"| node_sql
node_taskexec -.->|"runs collector"| node_system
node_pg -->|"invokes"| node_pgtools
node_sql -->|"invokes"| node_sqltools
node_system -->|"queries"| node_host
node_pg -->|"writes inventory"| node_staging
node_sql -->|"writes inventory"| node_staging
node_system -->|"writes inventory"| node_staging
node_taskexec -->|"provides tasks"| node_discovery
node_source -->|"matched by"| node_discovery
node_staging -->|"matched by"| node_discovery
node_discovery -->|"supplies files"| node_versioning
node_versioning -->|"writes versions"| node_filesystem
node_versioning -.->|"updates snapshot"| node_git
node_versioning -->|"records versions"| node_state
node_retention -->|"prunes versions"| node_filesystem
node_retention -->|"updates history"| node_state
node_runner -->|"runs prune"| node_retention
node_git -.->|"pushes commits"| node_remote
node_git -.->|"creates or updates PR"| node_github

click node_config "https://github.com/leistnerm/configbackup/blob/main/configbackup.example.yaml"
click node_runner "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_loader "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_taskexec "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_pg "https://github.com/leistnerm/configbackup/blob/main/collectors/postgresql/collect_postgresql.py"
click node_sql "https://github.com/leistnerm/configbackup/blob/main/collectors/sqlserver/Collect-SqlServerConfiguration.ps1"
click node_system "https://github.com/leistnerm/configbackup/blob/main/collectors/system/collect_system.py"
click node_discovery "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_versioning "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_retention "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_state "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_filesystem "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"
click node_git "https://github.com/leistnerm/configbackup/blob/main/configbackup.py"

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_runner,node_loader,node_taskexec toneBlue
class node_pg,node_sql,node_system,node_staging,node_pgtools,node_remote toneAmber
class node_discovery,node_versioning,node_retention,node_state toneMint
class node_filesystem,node_git,node_operator toneRose
class node_config toneTeal
class node_source,node_sqltools,node_host,node_github toneIndigo
```

## Components

### Run orchestration

- [Run entry and CLI](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Config loading](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Task execution](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`

### Capture and collectors

- [PostgreSQL collector](https://github.com/leistnerm/configbackup/blob/main/collectors/postgresql/collect_postgresql.py): `collectors/postgresql/collect_postgresql.py`
- [SQL Server collector](https://github.com/leistnerm/configbackup/blob/main/collectors/sqlserver/Collect-SqlServerConfiguration.ps1): `collectors/sqlserver/Collect-SqlServerConfiguration.ps1`
- [Guest-system collector](https://github.com/leistnerm/configbackup/blob/main/collectors/system/collect_system.py): `collectors/system/collect_system.py`
- **Generated artifact trees**

### Archive lifecycle

- [Source discovery](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Change detection and versions](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Retention and deletion](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Run state and manifests](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`

### Storage backends

- [Filesystem archive](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`
- [Git history](https://github.com/leistnerm/configbackup/blob/main/configbackup.py): `configbackup.py`

### Other components

- **Operator or scheduler**
- [YAML configuration](https://github.com/leistnerm/configbackup/blob/main/configbackup.example.yaml): `configbackup.example.yaml`
- **Files and directories**
- **PostgreSQL client tools**
- **SqlPackage and dbatools**
- **Host OS and commands**
- **Git remote**
- **GitHub PR service**

## Connections

- Operator or scheduler → Run entry and CLI: starts run
- YAML configuration → Config loading: provides settings
- Run entry and CLI → Config loading: loads configuration
- Config loading → Task execution: configures tasks
- Task execution → PostgreSQL collector: runs collector
- Task execution → SQL Server collector: runs collector
- Task execution → Guest-system collector: runs collector
- PostgreSQL collector → PostgreSQL client tools: invokes
- SQL Server collector → SqlPackage and dbatools: invokes
- Guest-system collector → Host OS and commands: queries
- PostgreSQL collector → Generated artifact trees: writes inventory
- SQL Server collector → Generated artifact trees: writes inventory
- Guest-system collector → Generated artifact trees: writes inventory
- Task execution → Source discovery: provides tasks
- Files and directories → Source discovery: matched by
- Generated artifact trees → Source discovery: matched by
- Source discovery → Change detection and versions: supplies files
- Change detection and versions → Filesystem archive: writes versions
- Change detection and versions → Git history: updates snapshot
- Change detection and versions → Run state and manifests: records versions
- Retention and deletion → Filesystem archive: prunes versions
- Retention and deletion → Run state and manifests: updates history
- Run entry and CLI → Retention and deletion: runs prune
- Git history → Git remote: pushes commits
- Git history → GitHub PR service: creates or updates PR
