Send backup notifications via telegram using Duplicacy Utils Telegram Bot

scripting

#1

Duplicacy Utils Telegram Bot

I created a telegram bot to use for my duplicacy-utils scripts, but then i though you can use it from any of your scripts (as long as you use telegram and want to be notified :stuck_out_tongue:).

The github link is: Duplicacy Utils Telegram Bot, but there’s no need to look there since that’s the server side!

How to use

  1. get the telegramToken from @DuplicacyUtilsTBPBot
  2. send a Post request to https://duplicacy-utils.tbp.land/userUpdate with the body containing a json encoded string with 2 fields:
    • content containing a string with your message
    • chat_id containing the telegram token from before

Example of usage in powershell:

$payload = @{
  content = "You can write anything: <code>this is monospaced</code>, <i>italic</i>, <b>bold</b>."
  chat_id = 1234567890
  }

Invoke-WebRequest `
  -Body (ConvertTo-Json -Compress -InputObject $payload) `
  -Method Post `
  -Uri "https://duplicacy-utils.tbp.land/userUpdate"

Example of usage as post-backup.bat script:

;@echo off
;Findstr -rbv ; %0 | powershell -ExecutionPolicy Bypass -c -
;goto:sCode


;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;; this is a bat file which calls powershell do do a web-request.
;;;;;;;;;;;;;;;;;; here starts the powershell code
;;;;;;;;;;;;;;;;;;

$payload = @{
  content = "Duplicacy backup finished."
  chat_id = 1234567890
  }

Invoke-WebRequest `
  -Body (ConvertTo-Json -Compress -InputObject $payload) `
  -Method Post `
  -Uri "https://duplicacy-utils.tbp.land/userUpdate"


;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;; the powershell code is finished now
;;;;;;;;;;;;;;;;;;


;:sCode
;echo done

You just have to save that piece of code as post-backup.bat as per Pre Command and Post Command Scripts and fill the chat_id with the one received from the bot.
By doing this: after each backup duplicacy calls the post-backup.bat script and you see a notification on telegram.


Scripts and utilities index