This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
GoSQLGuard is a Go-based database backup management tool designed for Kubernetes environments. It supports MySQL and PostgreSQL databases with flexible scheduling, retention policies, and multi-destination storage (local filesystem and S3).
The codebase follows a modular architecture with clear separation of concerns:
- Entry Point:
main.goinitializes configuration, starts the scheduler, and launches the admin server - Core Components:
pkg/backup/: Database backup logic with provider-based architecture for MySQL/PostgreSQLpkg/scheduler/: Cron-based scheduling system for automated backupspkg/storage/: Storage providers (local filesystem and S3)pkg/metadata/: Metadata tracking (file-based or MySQL-backed)pkg/adminserver/: Web UI and API endpointspkg/config/: Configuration parsing with environment variable substitution
make build # Build Docker image with auto-incrementing RC version
make push # Push to registry
make release # Build and push (full release)
make increment-rc # Just increment RC number
make help # View current version info# Start development environment
docker-compose up -d
# Run all tests
./scripts/run-tests.sh
# Run specific database tests
./scripts/run-mysql-tests.sh
./scripts/run-postgres-tests.sh
# Access services
# Admin UI: http://localhost:8888
# MinIO Console: http://localhost:9001 (minioadmin/minioadmin)The project uses Go's built-in testing framework. Integration tests are located in pkg/test/integration/ and require a running database instance.
The application uses YAML configuration with environment variable substitution (${VAR} syntax). Key configuration sections:
mysql/postgresql: Database connection settingslocal: Local storage configurations3: S3-compatible storage configurationbackupTypes: Defines backup schedules and retention policiesmetadata_database: Optional MySQL-based metadata storage
The admin server exposes:
- Web UI at
/with server-side rendered HTML templates - API endpoints under
/api/for backup operations - Prometheus metrics at
/metrics - Health check at
/health
- Provider Pattern: Database operations use a provider interface allowing easy extension for new database types
- Configuration Validation: All configuration is validated at startup with clear error messages
- Error Handling: Consistent error wrapping with context for debugging
- Metrics: All operations emit Prometheus metrics for monitoring
- Logging: Structured logging with configurable debug mode
pkg/config/config.go: Central configuration structure and validationpkg/backup/backup.go: Core backup orchestration logicpkg/scheduler/scheduler.go: Cron job managementpkg/pages/*.go: HTML template rendering for admin UIexample-configs/: Reference configurations for common scenarios