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
- Create a Telegram Chat
- Find out its chat-id
- Write a simple bash script that collects backup in tar.bz2 archive
- Break the archive into parts of 40MB (Telegram bots can send no more than 50MB at a time)
- Send all the parts of the archive to a pre-prepared Telegram chat
- Create a cron task to run the script daily
- Add the chat to the “archive” so that it does not bother with notifications, but you can always check it
If there is no particular desire to read the detailed description, I attach the bash script itself, which must be added to cron – https://gist.github.com/amorev/894e0e5e6a4ce604164eebae1b6e57aa
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.