Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Database Backup CLI (Spring Boot)

CI

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) with S3StorageService and LocalStorageService stubs
  • Spring Shell CLI entrypoint BackupCommand
  • Async configuration (@EnableAsync, named task executor) and retry helper
  • BackupProperties typed configuration and a BackupStatusService to track last backup

Next steps to implement:

  • Implement actual dump logic in strategy implementations (ProcessBuilder or JDBC+dump)
  • Integrate AWS SDK in S3StorageService for 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 LOCAL

Configuration is in src/main/resources/application.yml.

Prometheus / Actuator:

  • The project exposes actuator endpoints including /actuator/prometheus when running. Add Prometheus to scrape this endpoint.
  • Micrometer Prometheus registry is included (micrometer-registry-prometheus) and metrics emitted include backup_runs_total and backup_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_ID and AWS_SECRET_ACCESS_KEY, or configure the AWS CLI with aws 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.yml which runs mvn test on push and pull requests. This proves your Java skills to recruiters and keeps the build green.

About

A command-line interface (CLI) utility for backing up any type of database. The utility will support various database management systems (DBMS) such as MySQL, PostgreSQL, MongoDB, SQLite, and others. The tool will feature automatic backup scheduling, compression of backup files, storage options (local and cloud), and logging of backup activities.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages