A production-style backend system built in Go that demonstrates how a distributed backup platform can be architected using modern backend patterns.
This project implements:
- Clean Architecture
- gRPC client/server communication
- Worker pool concurrency
- Streaming database backups
- Pluggable storage adapters (local / S3 ready)
- Slack notifications
- Scheduler (cron-based)
- Dockerized development environment
- Prometheus metrics
- Graceful shutdown
- Context propagation
- Retry + backoff strategy
The goal of this project is to simulate how real infrastructure backup tools are designed and implemented.
backup-cli
│
▼
gRPC Client
│
▼
backup-daemon (gRPC Server)
│
├── Scheduler (cron jobs)
├── Worker Pool
├── Retry + Backoff
├── Metrics
│
▼
Backup Pipeline
(pg_dump → gzip → storage)
│
▼
Notifications (Slack)
+--------------------+
| backup-cli |
| gRPC Client |
+----------+---------+
|
v
+--------------------+
| backup-daemon |
| gRPC Server |
| :50051 |
| Metrics :9090 |
+----------+---------+
|
+-----------------+------------------+
| |
v v
+---------------+ +----------------+
| PostgreSQL | | MinIO/S3 |
| :5432 | | Object Store |
+---------------+ +----------------+
All services run locally through Docker Compose to simulate a production-like environment.
| Layer | Technology |
|---|---|
| Language | Go |
| RPC Transport | gRPC |
| Concurrency | Goroutines + Channels |
| Scheduler | robfig/cron |
| Compression | gzip |
| Storage | Local / S3 Adapter |
| Notifications | Slack Webhook |
| Metrics | Prometheus |
| Logging | Zap |
| Containerization | Docker + Docker Compose |
BackUpData/
│
├── cmd/
│ ├── backup-cli/ # CLI client
│ │ ├── cmd/
│ │ │ ├── backup.go
│ │ │ ├── root.go
│ │ │ └── schedule.go
│ │ └── main.go
│ │
│ └── backup-daemon/ # gRPC backup server
│ └── main.go
│
├── internal/
│ ├── compression/
│ │ └── gzip.go
│ │
│ ├── core/
│ │ ├── worker/
│ │ ├── backup_service.go
│ │ ├── full_backup.go
│ │ ├── interfaces.go
│ │ ├── job.go
│ │ ├── job_handler.go
│ │ └── strategy.go
│ │
│ ├── db/
│ │ └── postgres/
│ │ ├── backup.go
│ │ ├── executor.go
│ │ └── postgres.go
│ │
│ ├── storage/
│ │ ├── local/
│ │ ├── s3/
│ │ └── gcs/
│ │
│ ├── notification/
│ │ └── slack/
│ │ └── slack.go
│ │
│ ├── scheduler/
│ │ └── scheduler.go
│ │
│ └── metrics/
│ └── metrics.go
│
├── pkg/
│ ├── config/
│ └── logger/
│
├── proto/
│ ├── backup.proto
│ ├── backup.pb.go
│ └── backup_grpc.pb.go
│
├── backups/ # Generated backups
├── docker-compose.yml
├── Dockerfile
├── go.mod
└── go.sum
Business logic is isolated from external systems.
CLI / gRPC Layer
│
▼
Application Layer
│
▼
Core Business Logic
│
▼
Adapters (DB / Storage / Notifications)
This makes the system:
- extensible
- testable
- loosely coupled
Multiple backups can run concurrently.
+-------------+
| Job Channel |
+-------------+
│ │ │
▼ ▼ ▼
W1 W2 W3
Each worker processes backup jobs asynchronously.
Large databases are backed up using streaming I/O.
PostgreSQL
│
▼
pg_dump
│
▼
gzip compression
│
▼
storage adapter
This prevents loading the entire backup into memory.
The CLI communicates with the daemon using gRPC.
backup-cli
│
▼
RunBackup RPC
│
▼
backup-daemon
The daemon executes the backup pipeline and returns a response.
Backups can be automated using cron expressions.
Example:
0 2 * * *
Runs backups every day at 2 AM. Currently it runs every 10 seconds.
Slack notifications are sent after backup completion.
Example message:
Backup completed
Database: postgres-db
Duration: 3s
Size: 12000 bytes
The daemon exposes metrics at:
http://localhost:9090/metrics
Available metrics:
backup_success_total
backup_failure_total
backup_duration_seconds
These metrics allow integration with Grafana dashboards and alerts.
The system can be run in two ways:
- Local development
- Docker deployment
- Go 1.22+
- Docker
- Docker Compose
- protoc
- protoc-gen-go
- protoc-gen-go-grpc
Start databases:
docker compose up -dVerify containers:
docker psExpected services:
backup-postgres
backup-mysql
Connect to the database container:
docker exec -it backup-postgres psql -U backup -d testdbCreate sample table:
CREATE TABLE users(
id SERIAL PRIMARY KEY,
name TEXT
);Insert sample data:
INSERT INTO users(name) VALUES ('alice'), ('bob');Verify:
SELECT * FROM users;go run ./cmd/backup-daemonDaemon runs on:
- gRPC:
:50051 - Metrics:
:9090
In another terminal:
go run ./cmd/backup-cli backupExpected output:
Daemon Response: backup completed
ls backupsExample:
postgres-db.sql.gz
Inspect backup:
gunzip -c backups/postgres-db.sql.gz | headOpen browser:
http://localhost:9090/metrics
Example output:
backup_success_total 1
backup_failure_total 0
Run the full system with:
docker compose up --buildStop the system:
docker compose down+----------------+
| backup-cli |
+----------------+
|
v
+----------------+
| backup-daemon |
| gRPC Server |
+----------------+
| |
v v
+---------+ +--------------+
| Worker | | PostgreSQL |
+---------+ +--------------+
|
v
+---------------+
| Storage Layer |
+---------------+
|
v
+--------------+
| Notifications|
+--------------+
+---------------------+
| BackupService |
|---------------------|
| RunBackup() |
| StreamProgress() |
+---------------------+
|
v
+----------------------+
| BackupExecutor |
|----------------------|
| Run() |
+----------------------+
|
v
+----------------------+
| PostgresExecutor |
+----------------------+
Job Queue
│
┌──────────┼──────────┐
▼ ▼ ▼
Worker1 Worker2 Worker3
Krishna Thakur
Backend engineering learning project focused on building production-style infrastructure systems in Go.
- X (Twitter): https://x.com/i_krsna4
- LinkedIn: https://www.linkedin.com/in/krishnathakur1/
⭐ Star this repository if you find it helpful!