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 ).
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
- get the
telegramToken
from @DuplicacyUtilsTBPBot - send a
Post
request tohttps://duplicacy-utils.tbp.land/userUpdate
with thebody
containing ajson
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) `
-ContentType 'application/json' `
-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) `
-ContentType 'application/json' `
-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.
Here’s how the notification looks like
This is from a single duplicacy command
This is from multiple commands
- 1 is the header which informs the path of the current backup
- 2, 3 informs of the currently executing command (2=backup, 3=prune in my case)
- 4 informs the status of the status of the whole run (if any of the commands fail, then status = failure)