Backup in telegram

Telegram has long ceased to be just a messenger. For a very long time I have been using it for most notifications and even managing servers through writing my own bots. Telegram’s BOT API is very convenient.

Not so long ago, the site of my old client on wordpress was hacked and could affect the files of the site itself. As a result, I had to roll back to a rather old version, but fortunately the loss from hacking was minimal. To minimize accident losses, it was decided to create a daily data backup system. People are divided into two types – those who are already doing backups and those who will start soon 🙂

Keeping backups on the same server is an almost useless idea and you need to put backup files somewhere in a separate place. This is where Telegram comes to the rescue. The procedure is simple

  1. Create a Telegram Chat
  2. Find out its chat-id
  3. Write a simple bash script that collects backup in tar.bz2 archive
  4. Break the archive into parts of 40MB (Telegram bots can send no more than 50MB at a time)
  5. Send all the parts of the archive to a pre-prepared Telegram chat
  6. Create a cron task to run the script daily
  7. Add the chat to the “archive” so that it does not bother with notifications, but you can always check it
  8. Done!

If there is no particular desire to read the detailed description, I attach the bash script itself, which must be added to cron –

I’ll add a detailed description to this post when I understand that this is necessary. So far, I can clarify anything to you via Telegram – @amorev.

You may also like...