Protokoll #31358

ID31358
Zeitstempel2025-12-31 03:58:43.155582
Clientroot
IP145.224.72.245
Modellclaude-sonnet-4-20250514
Statuscompleted
Tokens1,638 (Input: 29, Output: 1,609)
Dauer78 ms
Request-Zeit2025-12-31 03:58:43.155582
Response-Zeit2025-12-31 03:58:43.233575

Request

{
    "event": "PreToolUse",
    "tool_name": "mcp__mcp-docs__docs_get",
    "tool_input": {
        "path": "\/betrieb\/file-backup-hook"
    }
}

Response

{
    "tool_response": [
        {
            "type": "text",
            "text": "{\n  \"success\": true,\n  \"doc\": {\n    \"id\": 60,\n    \"parent_id\": 55,\n    \"slug\": \"file-backup-hook\",\n    \"path\": \"\/betrieb\/file-backup-hook\",\n    \"title\": \"File Backup Hook\",\n    \"description\": \"\",\n    \"content\": \"<nav class=\\\"breadcrumb\\\">\\n    <a href=\\\"\/docs\\\">Dokumentation<\/a> &raquo; <a href=\\\"\/docs\/server\\\">Server<\/a> &raquo; File Backup Hook\\n<\/nav>\\n\\n<h1>File Backup Hook<\/h1>\\n<p class=\\\"doc-meta\\\"><strong>Erstellt:<\/strong> 2025-12-20 | <strong>Aktualisiert:<\/strong> 2025-12-20<\/p>\\n\\n<p>Automatisches Backup-System, das Dateien in der Datenbank sichert, <strong>bevor<\/strong> Claude Code sie mit Edit\/Write Tools ändert.<\/p>\\n\\n<table>\\n    <tr><th>Script<\/th><td>\/var\/www\/tools\/ki-protokoll\/claude-hook\/file_backup_hook.py<\/td><\/tr>\\n    <tr><th>Trigger<\/th><td>Claude PreToolUse (Edit, Write)<\/td><\/tr>\\n    <tr><th>Datenbank<\/th><td>ki_protokoll.file_backup_history<\/td><\/tr>\\n    <tr><th>Aktiviert<\/th><td>2025-12-20<\/td><\/tr>\\n<\/table>\\n\\n<h2>Funktionsweise<\/h2>\\n<pre><code>Claude Edit\/Write → PreToolUse Hook → file_backup_hook.py\\n                                           │\\n                                           ▼\\n                                    Datei existiert?\\n                                    In BACKUP_DIRS?\\n                                    Hash geändert?\\n                                           │\\n                                           ▼\\n                              ki_protokoll.file_backup_history\\n                              (version++, changed_by='claude-code-hook')<\/code><\/pre>\\n\\n<h2>Gesicherte Verzeichnisse<\/h2>\\n<ul>\\n    <li>\/var\/www\/dev.campus.systemische-tools.de\/src\/<\/li>\\n    <li>\/var\/www\/dev.campus.systemische-tools.de\/public\/<\/li>\\n    <li>\/var\/www\/dev.campus.systemische-tools.de\/scripts\/<\/li>\\n    <li>\/var\/www\/dev.campus.systemische-tools.de\/includes\/<\/li>\\n    <li>\/var\/www\/dev.campus.systemische-tools.de\/config\/<\/li>\\n    <li>\/var\/www\/prod.campus.systemische-tools.de\/* (analog)<\/li>\\n<\/ul>\\n\\n<h2>Ausgeschlossene Patterns<\/h2>\\n<ul>\\n    <li>\/vendor\/, \/node_modules\/, \/.git\/<\/li>\\n    <li>\/backups\/, \/tmp\/, \/logs\/, \/cache\/<\/li>\\n    <li>.log, .cache, .tmp<\/li>\\n    <li>Dateien > 10 MB<\/li>\\n<\/ul>\\n\\n<h2>Datenbank-Schema<\/h2>\\n<table>\\n    <tr><th>Spalte<\/th><th>Beschreibung<\/th><\/tr>\\n    <tr><td>id<\/td><td>Auto-increment ID<\/td><\/tr>\\n    <tr><td>file_path<\/td><td>Vollständiger Dateipfad<\/td><\/tr>\\n    <tr><td>file_content<\/td><td>Dateiinhalt (LONGTEXT)<\/td><\/tr>\\n    <tr><td>content_hash<\/td><td>SHA256 Hash<\/td><\/tr>\\n    <tr><td>file_size<\/td><td>Größe in Bytes<\/td><\/tr>\\n    <tr><td>version<\/td><td>Versionsnummer pro Datei<\/td><\/tr>\\n    <tr><td>change_type<\/td><td>created\/modified\/deleted<\/td><\/tr>\\n    <tr><td>changed_at<\/td><td>Timestamp<\/td><\/tr>\\n    <tr><td>changed_by<\/td><td>claude-code-hook<\/td><\/tr>\\n    <tr><td>reason<\/td><td>Backup-Grund<\/td><\/tr>\\n<\/table>\\n\\n<h2>Features<\/h2>\\n<ul>\\n    <li><strong>Hash-Vergleich:<\/strong> Vor jedem Backup wird der aktuelle Hash mit dem letzten verglichen. Bei identischem Hash wird kein neues Backup erstellt.<\/li>\\n    <li><strong>Versionierung:<\/strong> Jede Datei hat eine eigene Versionsnummer (1, 2, 3, ...)<\/li>\\n    <li><strong>Non-blocking:<\/strong> Der Hook gibt immer {\\\"continue\\\": true} zurück und blockiert nie Claude Code.<\/li>\\n<\/ul>\\n\\n<h2>Hooks-Konfiguration<\/h2>\\n<p>In <code>\/var\/www\/dev.campus.systemische-tools.de\/.claude\/settings.local.json<\/code>:<\/p>\\n<pre><code>{\\n  \\\"hooks\\\": {\\n    \\\"PreToolUse\\\": [\\n      {\\n        \\\"matcher\\\": \\\"Edit\\\",\\n        \\\"hooks\\\": [{\\n          \\\"type\\\": \\\"command\\\",\\n          \\\"command\\\": \\\"\/var\/www\/tools\/ki-protokoll\/claude-hook\/file_backup_hook.py\\\",\\n          \\\"timeout\\\": 10\\n        }]\\n      },\\n      {\\n        \\\"matcher\\\": \\\"Write\\\",\\n        \\\"hooks\\\": [{\\n          \\\"type\\\": \\\"command\\\",\\n          \\\"command\\\": \\\"\/var\/www\/tools\/ki-protokoll\/claude-hook\/file_backup_hook.py\\\",\\n          \\\"timeout\\\": 10\\n        }]\\n      }\\n    ]\\n  }\\n}<\/code><\/pre>\\n\\n<h2>Manueller Test<\/h2>\\n<pre><code>echo '{\\\"hook_event_name\\\": \\\"PreToolUse\\\", \\\"tool_name\\\": \\\"Edit\\\", \\\"tool_input\\\": {\\\"file_path\\\": \\\"\/var\/www\/dev.campus.systemische-tools.de\/src\/Controller\/DocsController.php\\\"}}' | \/var\/www\/tools\/ki-protokoll\/claude-hook\/file_backup_hook.py<\/code><\/pre>\\n\\n<h2>Backups abfragen<\/h2>\\n\\n<h4>Mit MCP-DB (empfohlen)<\/h4>\\n<pre><code># Letzte Backups anzeigen (via MCP-DB Tool)\\n# Verwendet automatisch sichere Authentifizierung ohne Passwort-Eingabe\\n\\n# Bestimmte Datei-History\\nSELECT version, file_size, changed_at\\nFROM file_backup_history\\nWHERE file_path = '\/pfad\/zur\/datei.php'\\nORDER BY version DESC;\\n\\n# Inhalt einer Version\\nSELECT file_content\\nFROM file_backup_history\\nWHERE id = 1;<\/code><\/pre>\\n\\n<h4>Mit direktem MySQL (Legacy, nicht empfohlen)<\/h4>\\n<pre><code># Hinweis: Direkter mysql-Zugriff erfordert Passwort-Eingabe\\n# Besser: Verwende MCP-DB Tool für sichere Authentifizierung\\n\\nmysql -u <username> -p ki_protokoll -e \\\"SELECT id, file_path, version FROM file_backup_history LIMIT 10;\\\"<\/code><\/pre>\\n\\n<h2>Unterschied zu anderen Systemen<\/h2>\\n<table>\\n    <tr><th>System<\/th><th>Trigger<\/th><th>Speicherort<\/th><th>Zweck<\/th><\/tr>\\n    <tr><td><strong>File Backup Hook<\/strong><\/td><td>Claude PreToolUse<\/td><td>DB (file_backup_history)<\/td><td>Automatisches Backup vor Code-Änderungen<\/td><\/tr>\\n    <tr><td>System Backup<\/td><td>Cron (03:00)<\/td><td>\/backup\/*.tar.gz<\/td><td>Vollständige System-Sicherung<\/td><\/tr>\\n    <tr><td>KI-Protokoll<\/td><td>Alle Claude Hooks<\/td><td>DB (protokoll)<\/td><td>Claude Request\/Response Logging<\/td><\/tr>\\n<\/table>\\n\\n<h2>Verwandte Module<\/h2>\\n<ul>\\n    <li><a href=\\\"\/docs\/modul\/ki-protokoll\\\">KI-Protokoll<\/a> - Claude Request\/Response Logging<\/li>\\n    <li><a href=\\\"\/docs\/modul\/backup\\\">System Backup<\/a> - Tägliche Vollsicherung<\/li>\\n    <li><a href=\\\"\/docs\/modul\/mariadb\\\">MariaDB<\/a> - Datenbank<\/li>\\n<\/ul>\",\n    \"status\": \"published\",\n    \"sort_order\": 5,\n    \"depth\": 1,\n    \"created_at\": \"2025-12-20T11:13:58\",\n    \"updated_at\": \"2025-12-27T15:58:19\"\n  }\n}"
        }
    ]
}
← Vorheriger Zur Liste Nächster →