Telegram

Did anyone manage to send the back-up via telegram? I can only send an image via a link, I was unable to send a file.

what do U mean
specify more with details

I need to send the backup of the rb by Telegram

The Telegram Bot API documentation regarding sending files is here:
https://core.telegram.org/bots/api#sending-files

Not sure this works with fetch command… Probably not.

you can also do this with via mail instead

Some screenshot of my telegram bot…
WhatsApp Image 2020-12-06 at 6.41.33 AM.jpeg
WhatsApp Image 2020-12-06 at 6.41.33 AM (3).jpeg
WhatsApp Image 2020-12-06 at 6.41.33 AM (2).jpeg
WhatsApp Image 2020-12-06 at 6.41.33 AM (1).jpeg
WhatsApp Image 2020-12-06 at 6.41.33 AM (4).jpeg

Answer is: No

I did not manage to send directly from Mikrotik, because “fetch” tool does not support sending files. I managed to send using Raspberry Pi:

Generate SSH keys on raspberry Pi and its upload public key to each router. Then pretty much use this bash script:

#!/bin/bash

ROUTER=$1
TITLE=$2

SSHUSER="admin"
SSHIDENTITY="~/.ssh/mikrotik"

TELEGRAMCHATID="1234567890"
TELEGRAMAPIKEY="0000000000:AAAAAAAAA-bbbbbbbbbbbbbbb-cccccccccc"


OUTPUT=$(ssh -i "$SSHIDENTITY" "$SSHUSER@$ROUTER" "/export")
RES=$?

if [[ $RES -eq 0 ]]; then
        TMPFILE="/dev/shm/export_${TITLE}_$(date +%Y%m%d)"
        echo "# Address: $ROUTER" > $TMPFILE
        echo "#" >> $TMPFILE
        echo -e "$OUTPUT" >> $TMPFILE

        curl -s -F "chat_id=$TELEGRAMCHATID" -F "document=@$TMPFILE" https://api.telegram.org/bot$TELEGRAMAPIKEY/sendDocument > /dev/null
        rm $TMPFILE
fi

Then in crontab:

# Backup Mikrotik routers
0 2 * * * /storage/tasks/others/mikrotik-backup.sh aaaaaaaaaaaa.sn.mynetname.net name1
0 2 * * * /storage/tasks/others/mikrotik-backup.sh aaaaaaaaaaaa.sn.mynetname.net name2
0 2 * * * /storage/tasks/others/mikrotik-backup.sh aaaaaaaaaaaa.sn.mynetname.net name3

EDIT: Don’t like or don’t have Raspberry Pi? Get the cheapest Linode instance then and host such script on it. 5 dollars per month for the cheapest instance AFAIK + you can do other stuff on it.

Wow :astonished_face: :exploding_head:, that is one sick script!!
Would you mind sharing some of those scripts so we could integrate it with our telegram bot? I would really appreciate it

I do send backup using gmail, both readable file and bin backup.
Easy to setup and work all the time.