Community discussions

MikroTik App
 
joserf
just joined
Topic Author
Posts: 4
Joined: Mon Apr 28, 2014 5:51 pm

Telegram

Tue Sep 01, 2020 10:38 pm

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.
 
ShayanPAL
newbie
Posts: 47
Joined: Thu Dec 19, 2019 12:20 pm

Re: Telegram

Tue Sep 01, 2020 11:27 pm

what do U mean
specify more with details
 
joserf
just joined
Topic Author
Posts: 4
Joined: Mon Apr 28, 2014 5:51 pm

Re: Telegram

Wed Sep 02, 2020 3:23 pm

I need to send the backup of the rb by Telegram
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: Telegram

Wed Sep 02, 2020 4:06 pm

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.
 
ShayanPAL
newbie
Posts: 47
Joined: Thu Dec 19, 2019 12:20 pm

Re: Telegram

Wed Sep 02, 2020 8:12 pm

you can also do this with via mail instead
 
usmans
Member Candidate
Member Candidate
Posts: 115
Joined: Sun Aug 29, 2010 11:54 pm

Re: Telegram

Sun Dec 06, 2020 4:51 am

Some screenshot of my telegram bot...
You do not have the required permissions to view the files attached to this post.
 
User avatar
erkexzcx
Member Candidate
Member Candidate
Posts: 263
Joined: Mon Oct 07, 2019 11:42 pm

Re: Telegram

Sun Dec 06, 2020 1:26 pm

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.
 
User avatar
mpuria
just joined
Posts: 12
Joined: Sun Dec 06, 2020 12:56 am
Location: Philippines
Contact:

Re: Telegram

Fri Apr 16, 2021 10:09 am

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
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Telegram

Fri Apr 16, 2021 1:30 pm

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

Who is online

Users browsing this forum: rogerioqueiroz and 24 guests