Selain menggunakan email, backup konfigurasi MikroTik juga bisa dikirim langsung ke Telegram menggunakan Bot. Metode ini sangat praktis karena file backup akan langsung tersimpan di chat Telegram Anda.
🎯 Tujuan Konfigurasi
- Membuat file
.backup(binary) - Membuat file
.rsc(export readable) - Mengirim file ke Telegram Bot
- Mengirim notifikasi sukses backup
- Menjalankan otomatis via scheduler
🪄 STEP 1 — Membuat Bot Telegram
- Buka Telegram
- Cari @BotFather
- Ketik
/start - Ketik
/newbot - Ikuti instruksi sampai mendapatkan BOT TOKEN
Contoh token:
123456789:AAE_xxxxxxxxxxxxxxxxxxxxxx
🪄 STEP 2 — Mendapatkan Chat ID
- Kirim pesan ke bot (misalnya: "halo")
- Buka browser dan akses:
https://api.telegram.org/botTOKEN/getUpdates
Ganti TOKEN dengan bot token Anda.
Cari bagian berikut:
"chat":{"id":123456789}
Angka tersebut adalah CHAT ID Anda.
🛠 STEP 3 — Membuat Script AUTO_BACKUP_TO_TELEGRAM
Masuk ke System → Scripts → Add
Beri nama: AUTO_BACKUP_TO_TELEGRAM
Isi script berikut:
# =====================================
# AUTO BACKUP MIKROTIK TO TELEGRAM
# =====================================
# ===== CONFIG =====
:local botToken "ISI_BOT_TOKEN_DISINI"
:local chatId "ISI_CHAT_ID_DISINI"
:local delayTime 5s
# ===== SYSTEM INFO =====
:local identity [/system identity get name]
:local rawDate [/system clock get date]
:local day [:pick $rawDate 4 6]
:local monthStr [:pick $rawDate 0 3]
:local year [:pick $rawDate 7 11]
:local month "01"
:if ($monthStr="jan") do={:set month "01"}
:if ($monthStr="feb") do={:set month "02"}
:if ($monthStr="mar") do={:set month "03"}
:if ($monthStr="apr") do={:set month "04"}
:if ($monthStr="may") do={:set month "05"}
:if ($monthStr="jun") do={:set month "06"}
:if ($monthStr="jul") do={:set month "07"}
:if ($monthStr="aug") do={:set month "08"}
:if ($monthStr="sep") do={:set month "09"}
:if ($monthStr="oct") do={:set month "10"}
:if ($monthStr="nov") do={:set month "11"}
:if ($monthStr="dec") do={:set month "12"}
:local cleanDate ($year . "-" . $month . "-" . $day)
:local waktu [/system clock get time]
:local namafile ($identity . "-" . $cleanDate)
# ===== PROSES BACKUP =====
/system backup save name=$namafile
/export file=$namafile
:delay $delayTime
# ===== KIRIM FILE .backup =====
/tool fetch \
url=("https://api.telegram.org/bot".$botToken."/sendDocument") \
http-method=post \
http-data=("chat_id=".$chatId) \
http-header-field="Content-Type: multipart/form-data" \
upload=yes \
src-path=($namafile.".backup")
:delay 3s
# ===== KIRIM FILE .rsc =====
/tool fetch \
url=("https://api.telegram.org/bot".$botToken."/sendDocument") \
http-method=post \
http-data=("chat_id=".$chatId) \
http-header-field="Content-Type: multipart/form-data" \
upload=yes \
src-path=($namafile.".rsc")
:delay 3s
# ===== KIRIM NOTIFIKASI =====
/tool fetch \
url=("https://api.telegram.org/bot".$botToken."/sendMessage?chat_id=".$chatId."&text=Backup ".$identity." ".$cleanDate." berhasil") \
keep-result=no
# ===== HAPUS FILE LOKAL =====
/file remove ($namafile . ".backup")
/file remove ($namafile . ".rsc")
Klik Apply → OK.
📅 STEP 4 — Membuat Scheduler Otomatis
Masuk ke System → Scheduler → Add
- Name: auto-backup-telegram
- Interval: 1d
- Start Time: 02:00:00
- On Event:
/system script run AUTO_BACKUP_TO_TELEGRAM
Sekarang backup akan berjalan otomatis setiap hari jam 02:00.
⚠️ Catatan Penting
- Direct upload file ke Telegram umumnya hanya berjalan di RouterOS v7 tertentu
- RouterOS v6 biasanya hanya mendukung upload FTP/SFTP
- Jika gagal, gunakan metode relay via VPS (SFTP → Server → Telegram)
- Pastikan DNS dan koneksi HTTPS berjalan normal
✅ Penutup
Dengan konfigurasi ini, MikroTik dapat mengirim backup otomatis langsung ke Telegram. Metode ini sangat cocok untuk monitoring cepat dan penyimpanan cadangan ringan.
Untuk kebutuhan produksi skala besar, disarankan tetap menyimpan backup ke server eksternal sebagai lapisan keamanan tambahan.
Selamat membangun sistem backup yang lebih modern dan tangguh 🚀
