This is a simple solution to push the contents of a specified folder to respective Minio buckets with similar names.
I used the latest version of Golang (1.18 as of writing this), so you may need to refactor accordingly.
This repo uses some experimental features in Go 1.18. This is the slices package using generics on 1.18. For further info, please refer to https://pkg.go.dev/golang.org/x/exp/slices
- Clone this repo
git clone https://github.com/benzerbett/backupservice
- Install dependencies
cd backupservice go get
- Set up environment variables. The variables are:
- MINIO_ENDPOINT
- MINIO_ACCESSKEY
- MINIO_SECRET
- BACKUP_FILES_DIR
nano .env
- To test it locally, simply run the
main.go
file
go run main.go
- Build & deploy
go build -o backupservice
To deploy, you can schedule this as a cron job or otherwise, depending on your environment.
- Decouple & clean up the string comparisons to match container names. Perhaps a mapping config?
- Better logging (logrus?)
- Refactor to use standard Go library, (remove experimental 1.18 slices feature)