Page 1 of 1

Telegram

Posted: Tue Sep 01, 2020 10:38 pm
by joserf
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.

Re: Telegram

Posted: Tue Sep 01, 2020 11:27 pm
by ShayanPAL
what do U mean
specify more with details

Re: Telegram

Posted: Wed Sep 02, 2020 3:23 pm
by joserf
I need to send the backup of the rb by Telegram

Re: Telegram

Posted: Wed Sep 02, 2020 4:06 pm
by eworm
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.

Re: Telegram

Posted: Wed Sep 02, 2020 8:12 pm
by ShayanPAL
you can also do this with via mail instead

Re: Telegram

Posted: Sun Dec 06, 2020 4:51 am
by usmans
Some screenshot of my telegram bot...

Re: Telegram

Posted: Sun Dec 06, 2020 1:26 pm
by erkexzcx
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.

Re: Telegram

Posted: Fri Apr 16, 2021 10:09 am
by mpuria
Some screenshot of my telegram bot...
Wow 😲 🤯, 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

Re: Telegram

Posted: Fri Apr 16, 2021 1:30 pm
by Jotne
I do send backup using gmail, both readable file and bin backup.
Easy to setup and work all the time.