Add notification feature to backup scripts for various services

Enhance backup scripts for Nextcloud, Gitea, Paperless, Vaultwarden, Immich, and VPS configurations by adding Telegram notifications upon completion. Include details such as backup size and objects backed up. Update backup documentation to reflect these changes and ensure clarity on backup processes and retention policies.
This commit is contained in:
2026-02-27 20:42:30 +03:00
parent 56cee83198
commit f319133cee
21 changed files with 1048 additions and 168 deletions

View File

@@ -37,6 +37,18 @@ ssh "${SSH_OPTS[@]}" "${VPS_USER}@${VPS_HOST}" "tar -chzf - -C / \
var/www/katykhin.store" > "$ARCHIVE"
chmod 600 "$ARCHIVE"
echo "Бэкап MTProto (VPS DE): $ARCHIVE ($(du -h "$ARCHIVE" | cut -f1))"
echo "Бэкап MTProto (VPS DE): $ARCHIVE ($(du --apparent-size -h "$ARCHIVE" | cut -f1))"
find "$BACKUP_ROOT" -name 'mtproto-config-*.tar.gz' -mtime +$RETENTION_DAYS -delete
NOTIFY_SCRIPT="${NOTIFY_SCRIPT:-/root/scripts/notify-telegram.sh}"
if [ -x "$NOTIFY_SCRIPT" ]; then
SIZE=$(du --apparent-size -h "$ARCHIVE" | cut -f1)
SIZE_BYTES=$(stat -c%s "$ARCHIVE" 2>/dev/null || echo 0)
BODY="Резервное копирование завершено.
Объекты: конфиги MTProto, nginx, Let's Encrypt, сайт (VPS DE).
Размер копии: ${SIZE}."
[ "$SIZE_BYTES" -lt 1024 ] 2>/dev/null && BODY="${BODY}
⚠️ Подозрительно малый размер — проверьте SSH и наличие файлов на VPS."
"$NOTIFY_SCRIPT" "🌐 VPS MTProto (DE)" "$BODY" || true
fi