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

@@ -30,7 +30,7 @@ else
fi
if [ -s "$OUTPUT" ]; then
echo "Создан: $OUTPUT ($(du -h "$OUTPUT" | cut -f1))"
echo "Создан: $OUTPUT ($(du --apparent-size -h "$OUTPUT" | cut -f1))"
else
echo "Ошибка: дамп пустой или не создан."
rm -f "$OUTPUT"
@@ -39,3 +39,15 @@ fi
# Удалить дампы старше RETENTION_DAYS
find "$BACKUP_DIR" -name 'immich-db-*.sql.gz' -mtime +$RETENTION_DAYS -delete
NOTIFY_SCRIPT="${NOTIFY_SCRIPT:-/root/scripts/notify-telegram.sh}"
if [ -x "$NOTIFY_SCRIPT" ]; then
SIZE=$(du --apparent-size -h "$OUTPUT" | cut -f1)
SIZE_BYTES=$(stat -c%s "$OUTPUT" 2>/dev/null || echo 0)
BODY="Резервное копирование завершено.
Объекты: дамп БД Immich (PostgreSQL, VM 200).
Размер копии: ${SIZE}."
[ "$SIZE_BYTES" -lt 10240 ] 2>/dev/null && BODY="${BODY}
⚠️ Подозрительно малый размер — проверьте скрипт на VM 200 и наличие данных в БД."
"$NOTIFY_SCRIPT" "🗄️ Immich (БД)" "$BODY" || true
fi