DEV Community


I've created a Bot to dump my database and send it to my team in Golang.

daniellunsc profile image Daniel Luna ・2 min read

Go-dumper code: Github-link

What is it and motivation

This week one of my co-workers asked for a database dump to update his local database and work with latest data. Believe it or not, me and other co-worker forgot about it and the asker wait for about 1 hour until remind us.

Thinking about that and my desire to pratice my Golang, I've created a bot that dumps the database based on /dump command. Simple as that.

The bot answers only on an allowed chat, in the case, my dev team.


How I made it

I've googled for a tool that could dump my database, that tool is Go-mysqldump.

After I finished It, I refactored part of the code to make it easy to understand and maintain, my plan is to use it at work too.

The next step was simply add the telegram bot, and for it I used a nice Wrapper: Go-telegram-bot-api

Now I'm writing this post. The code is not perfect yet and has some languages mixed (Portuguese and English) but I'm working to refactor It and make it easier to understand.

How to use on your own.

You need a Telegram bot created.

Via Docker

  • You can simple replace the env at Dockerfile
  • Then build the image: $ docker build -t go-dumper .
  • Then run the container: $ docker run go-dumper

Via configuration yaml file

  • You can fullfill your credentials at Config File

  • On project folder, run $ go get ./...

  • Then run $ go run config.go databasehelpers.go main.go

After go-dumper starts, the bot will start to answer.

Want to contribute?

I'm thinking about adding some tests!

Feel free to open issues and request new features on the repo.

Feedbacks are very welcome!

ps: I've been learning Golang for the past 2 days and I'm loving it!.

I followed this post to learn how to use environment variables and config file. Thanks!

Discussion (0)

Editor guide