This project is a Spring Boot-based command-line utility to perform database backups.
What this scaffold provides:
- Domain model (
BackupRequest,BackupResult, enums) - Strategy pattern for DB-specific backup logic (
BackupStrategy,PostgresBackupStrategy,MySqlBackupStrategy) - Factory to select strategies dynamically (
BackupStrategyFactory) - Storage abstraction (
StorageService) withS3StorageServiceandLocalStorageServicestubs - Spring Shell CLI entrypoint
BackupCommand - Async configuration (
@EnableAsync, named task executor) and retry helper BackupPropertiestyped configuration and aBackupStatusServiceto track last backup
Next steps to implement:
- Implement actual dump logic in strategy implementations (ProcessBuilder or JDBC+dump)
- Integrate AWS SDK in
S3StorageServicefor real uploads - Add Micrometer and Spring Boot Actuator for metrics and health integration
- Add unit and integration tests for factory, CLI, and storage
Usage (after building):
Run the Spring Boot app and use the shell command:
./mvnw spring-boot:run
# then in shell:
start-backup --dbType POSTGRES --host 127.0.0.1 --port 5432 --username user --password pass --databaseName db --compress false --storageDestination LOCALConfiguration is in src/main/resources/application.yml.
Prometheus / Actuator:
- The project exposes actuator endpoints including
/actuator/prometheuswhen running. Add Prometheus to scrape this endpoint. - Micrometer Prometheus registry is included (
micrometer-registry-prometheus) and metrics emitted includebackup_runs_totalandbackup_duration_ms.
Security and secrets:
- Do not commit AWS credentials or any secrets to Git. Use environment variables or a secrets manager (AWS Secrets Manager / Vault) in production.
AWS credentials (local dev):
- Set environment variables
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY, or configure the AWS CLI withaws configure. - For CI, use repository secrets or the cloud provider's role-based credentials (do NOT store credentials in the repository).
CI / GitHub Actions:
- A simple GitHub Actions workflow is included at
.github/workflows/ci.ymlwhich runsmvn teston push and pull requests. This proves your Java skills to recruiters and keeps the build green.