Add telegram bot functionality
This commit is contained in:
parent
0a671b1a0a
commit
95ace5f95c
@ -1,6 +1,6 @@
|
||||
FROM alpine
|
||||
|
||||
RUN apk update && apk add openssl openssh
|
||||
RUN apk update && apk add openssl openssh curl
|
||||
|
||||
COPY backup.sh .
|
||||
|
||||
|
@ -8,6 +8,8 @@ docker run \
|
||||
-v /path/to/output:/output \
|
||||
-v /path/to/key1.pub:/keys/key1.pub:ro \
|
||||
-v /path/to/key2.pub:/keys/key2.pub:ro \
|
||||
-e TELEGRAM_BOT_TOKEN=verysecretbottoken \
|
||||
-e TELEGRAM_CHAT_IDS=1337,42069,-12345 \
|
||||
backupinator
|
||||
```
|
||||
|
||||
|
21
backup.sh
21
backup.sh
@ -25,3 +25,24 @@ for keyfile in $(ls /keys); do
|
||||
rm $tmpkey
|
||||
done
|
||||
|
||||
if [ ! -z ${TELEGRAM_BOT_TOKEN+x} ]; then
|
||||
echo $TELEGRAM_CHAT_IDS | sed -n 1'p' | tr ',' '\n' | while read chat_id; do
|
||||
echo "sending messages to $chat_id..."
|
||||
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
|
||||
-F chat_id="$chat_id" \
|
||||
-F text="Backup time."
|
||||
echo ""
|
||||
|
||||
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument" \
|
||||
-F chat_id="$chat_id" \
|
||||
-F document=@/out/backup.tar.gz.enc
|
||||
echo ""
|
||||
|
||||
for keyfile in $(ls /out/key-*); do
|
||||
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendDocument" \
|
||||
-F chat_id="$chat_id" \
|
||||
-F document="@$keyfile"
|
||||
echo ""
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user