{"title":"Backup e ripristino","slug":"backup-restore","category":"guides","summary":"Esporti le sue memorie per backup, migrare tra menti, ripristinare dopo perdita di dati.","audience":["human","llm"],"tags":["guide","backup","restore","migration"],"difficulty":"beginner","updated":"2026-06-27","word_count":270,"read_minutes":1,"lang":"it","translated":true,"requested_lang":"it","content_markdown":"\n# Backup e ripristino\n\nSynapse fornisce export/import completo per backup della memoria, migrazione e\ndisaster recovery. Questa guida copre le operazioni essenziali.\n\n## Export\n\n### Export completo della mente\n\nEsporti tutte le memorie in una mente come JSON:\n\n```bash\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     https://synapse.schaefer.zone/memory/mind-export > backup.json\n```\n\nFormato della risposta:\n\n```json\n{\n  \"mind_id\": \"m_xyz789\",\n  \"mind_name\": \"Work Mind\",\n  \"exported_at\": \"2026-06-27T...\",\n  \"memory_count\": 142,\n  \"memories\": [\n    {\n      \"id\": \"mem_001\",\n      \"category\": \"identity\",\n      \"key\": \"user_name\",\n      \"content\": \"Michael Schäfer\",\n      \"tags\": [\"person\", \"identity\"],\n      \"priority\": \"critical\",\n      \"source\": \"user\",\n      \"verified\": true,\n      \"created_at\": \"2026-06-15T...\",\n      \"updated_at\": \"2026-06-27T...\"\n    }\n  ]\n}\n```\n\n### Export incrementale (diff)\n\nEsporti solo le memorie modificate da un timestamp:\n\n```bash\nSINCE=$(date -d \"2026-06-01\" +%s)\ncurl -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n     \"https://synapse.schaefer.zone/memory/diff?since=$SINCE\" > incremental.json\n```\n\nRisposta:\n\n```json\n{\n  \"added\": [...],\n  \"updated\": [...],\n  \"deleted\": [...]\n}\n```\n\n### Backup automatizzati\n\nPianifichi backup giornalieri tramite cron:\n\n```bash\ncurl -X POST https://synapse.schaefer.zone/cron \\\n  -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"schedule\": \"0 2 * * *\",\n    \"endpoint\": \"https://synapse.schaefer.zone/memory/mind-export\",\n    \"method\": \"GET\",\n    \"headers\": {\"Authorization\": \"Bearer YOUR_MIND_KEY\"}\n  }'\n```\n\n> [!NOTE]\n> L'endpoint cron riceve la risposta ma non la memorizza. Per backup reali,\n> punti il cron al suo server di backup che salva la risposta.\n\n### Meglio: script di backup esterno\n\n```bash\n#!/bin/bash\n# backup-synapse.sh\nMIND_KEY=\"${SYNAPSE_MIND_KEY}\"\nDATE=$(date +%Y%m%d)\nBACKUP_DIR=\"/backups/synapse\"\n\nmkdir -p \"$BACKUP_DIR\"\n\ncurl -s -H \"Authorization: Bearer $MIND_KEY\" \\\n     https://synapse.schaefer.zone/memory/mind-export \\\n     > \"$BACKUP_DIR/synapse-$DATE.json\"\n\n# Keep last 30 days\nfind \"$BACKUP_DIR\" -name \"synapse-*.json\" -mtime +30 -delete\n\necho \"Backup saved: $BACKUP_DIR/synapse-$DATE.json\"\n```\n\nAggiunga a crontab:\n\n```cron\n0 2 * * * /usr/local/bin/backup-synapse.sh\n```\n\n## Ripristino\n\n### Ripristino sulla stessa mente\n\n```bash\n# Parse backup and re-POST each memory\njq -c '.memories[]' backup.json | while read mem; do\n  curl -X POST https://synapse.schaefer.zone/memory \\\n    -H \"Authorization: Bearer YOUR_MIND_KEY\" \\\n    -H \"Content-Type: application/json\" \\\n    -d \"$(echo \"$mem\" | jq '{category, key, content, tags, priority}')\"\ndone\n```\n\n### Ripristino su una nuova mente\n\n```bash\n# 1. Create new mind\nNEW_KEY=$(curl -s -X POST https://synapse.schaefer.zone/minds \\\n  -H \"Authorization: Bearer YOUR_JWT\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"name\":\"Restored Mind\",\"description\":\"Restore from backup\"}' \\\n  | jq -r .mind_key)\n\n# 2. Import memories to new mind\njq -c '.memories[]' backup.json | while read mem; do\n  curl -X POST https://synapse.schaefer.zone/memory \\\n    -H \"Authorization: Bearer $NEW_KEY\" \\\n    -H \"Content-Type: application/json\" \\\n    -d \"$(echo \"$mem\" | jq '{category, key, content, tags, priority}')\"\ndone\n```\n\n### Script di ripristino in Python\n\n```python\nimport json\nimport requests\n\nURL = \"https://synapse.schaefer.zone\"\nMIND_KEY = \"mk_...\"\n\ndef restore(backup_file):\n    with open(backup_file) as f:\n        data = json.load(f)\n    \n    for mem in data[\"memories\"]:\n        requests.post(\n            f\"{URL}/memory\",\n            headers={\n                \"Authorization\": f\"Bearer {MIND_KEY}\",\n                \"Content-Type\": \"application/json\"\n            },\n            json={\n                \"category\": mem[\"category\"],\n                \"key\": mem[\"key\"],\n                \"content\": mem[\"content\"],\n                \"tags\": mem.get(\"tags\", []),\n                \"priority\": mem.get(\"priority\", \"normal\")\n            }\n        )\n    \n    print(f\"Restored {len(data['memories'])} memories\")\n\nrestore(\"backup.json\")\n```\n\n## Migrazione tra menti\n\n```python\ndef migrate_memories(source_key, target_key):\n    \"\"\"Migrate all memories from source mind to target mind.\"\"\"\n    # Export from source\n    r = requests.get(\n        f\"{URL}/memory/mind-export\",\n        headers={\"Authorization\": f\"Bearer {source_key}\"}\n    )\n    data = r.json()\n    \n    # Import to target\n    for mem in data[\"memories\"]:\n        requests.post(\n            f\"{URL}/memory\",\n            headers={\n                \"Authorization\": f\"Bearer {target_key}\",\n                \"Content-Type\": \"application/json\"\n            },\n            json={\n                \"category\": mem[\"category\"],\n                \"key\": mem[\"key\"],\n                \"content\": mem[\"content\"],\n                \"tags\": mem.get(\"tags\", []),\n                \"priority\": mem.get(\"priority\", \"normal\")\n            }\n        )\n    \n    print(f\"Migrated {len(data['memories'])} memories\")\n```\n\n## Backup di altri dati\n\nNon dimentichi di fare backup di:\n\n| Tipo di dato | Endpoint |\n|-----------|----------|\n| Memorie | `GET /memory/mind-export` |\n| Attività | `GET /mind/tasks` |\n| Script | `GET /scripts` |\n| Webhook | `GET /webhooks` |\n| Cron job | `GET /cron` |\n| Variabili | `GET /var` |\n| Cronologia chat | `GET /chat/history?limit=10000` |\n\n## Verifica\n\nDopo il ripristino, verifichi:\n\n```bash\n# Count memories\ncurl -s -H \"Authorization: Bearer $KEY\" \\\n     https://synapse.schaefer.zone/memory/stats | jq .total\n\n# Compare with backup\njq .memory_count backup.json\n```\n\n## Best practice\n\n> [!TIP]\n> - **Backup giornaliero** — automatizzi con cron\n> - **Testi i ripristini** — un backup che non può ripristinare è inutile\n> - **Mantenga versioni multiple** — almeno 30 giorni\n> - **Salvi offsite** — S3, Backblaze B2, ecc.\n> - **Cifri i backup sensibili** — le memorie possono contenere PII\n> - **Documenti il processo di ripristino** — lo dimenticherà quando le servirà\n\n## Prossimi passi\n\n- [Memory API](/docs/api/memory)\n- [Cron & Scheduler](/docs/api/cron) — per backup automatizzati\n","content_html":"<h1>Backup e ripristino</h1>\n<p>Synapse fornisce export/import completo per backup della memoria, migrazione e\ndisaster recovery. Questa guida copre le operazioni essenziali.</p>\n<h2>Export</h2>\n<h3>Export completo della mente</h3>\n<p>Esporti tutte le memorie in una mente come JSON:</p>\n<pre><code class=\"hljs language-bash\">curl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     https://synapse.schaefer.zone/memory/mind-export &gt; backup.json</code></pre><p>Formato della risposta:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;mind_id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;m_xyz789&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;mind_name&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Work Mind&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;exported_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;memory_count&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-number\">142</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;memories&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span>\n    <span class=\"hljs-punctuation\">{</span>\n      <span class=\"hljs-attr\">&quot;id&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;mem_001&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;category&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;identity&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;key&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;user_name&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;content&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;Michael Schäfer&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;tags&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span><span class=\"hljs-string\">&quot;person&quot;</span><span class=\"hljs-punctuation\">,</span> <span class=\"hljs-string\">&quot;identity&quot;</span><span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;priority&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;critical&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;source&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;user&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;verified&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">true</span></span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;created_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-15T...&quot;</span><span class=\"hljs-punctuation\">,</span>\n      <span class=\"hljs-attr\">&quot;updated_at&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-string\">&quot;2026-06-27T...&quot;</span>\n    <span class=\"hljs-punctuation\">}</span>\n  <span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>Export incrementale (diff)</h3>\n<p>Esporti solo le memorie modificate da un timestamp:</p>\n<pre><code class=\"hljs language-bash\">SINCE=$(<span class=\"hljs-built_in\">date</span> -d <span class=\"hljs-string\">&quot;2026-06-01&quot;</span> +%s)\ncurl -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n     <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone/memory/diff?since=<span class=\"hljs-variable\">$SINCE</span>&quot;</span> &gt; incremental.json</code></pre><p>Risposta:</p>\n<pre><code class=\"hljs language-json\"><span class=\"hljs-punctuation\">{</span>\n  <span class=\"hljs-attr\">&quot;added&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span>...<span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;updated&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span>...<span class=\"hljs-punctuation\">]</span><span class=\"hljs-punctuation\">,</span>\n  <span class=\"hljs-attr\">&quot;deleted&quot;</span><span class=\"hljs-punctuation\">:</span> <span class=\"hljs-punctuation\">[</span>...<span class=\"hljs-punctuation\">]</span>\n<span class=\"hljs-punctuation\">}</span></code></pre><h3>Backup automatizzati</h3>\n<p>Pianifichi backup giornalieri tramite cron:</p>\n<pre><code class=\"hljs language-bash\">curl -X POST https://synapse.schaefer.zone/cron \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{\n    &quot;schedule&quot;: &quot;0 2 * * *&quot;,\n    &quot;endpoint&quot;: &quot;https://synapse.schaefer.zone/memory/mind-export&quot;,\n    &quot;method&quot;: &quot;GET&quot;,\n    &quot;headers&quot;: {&quot;Authorization&quot;: &quot;Bearer YOUR_MIND_KEY&quot;}\n  }&#x27;</span></code></pre><div class=\"callout callout-note\">L'endpoint cron riceve la risposta ma non la memorizza. Per backup reali,\npunti il cron al suo server di backup che salva la risposta.</div><h3>Meglio: script di backup esterno</h3>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-meta\">#!/bin/bash</span>\n<span class=\"hljs-comment\"># backup-synapse.sh</span>\nMIND_KEY=<span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">${SYNAPSE_MIND_KEY}</span>&quot;</span>\nDATE=$(<span class=\"hljs-built_in\">date</span> +%Y%m%d)\nBACKUP_DIR=<span class=\"hljs-string\">&quot;/backups/synapse&quot;</span>\n\n<span class=\"hljs-built_in\">mkdir</span> -p <span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">$BACKUP_DIR</span>&quot;</span>\n\ncurl -s -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$MIND_KEY</span>&quot;</span> \\\n     https://synapse.schaefer.zone/memory/mind-export \\\n     &gt; <span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">$BACKUP_DIR</span>/synapse-<span class=\"hljs-variable\">$DATE</span>.json&quot;</span>\n\n<span class=\"hljs-comment\"># Keep last 30 days</span>\nfind <span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">$BACKUP_DIR</span>&quot;</span> -name <span class=\"hljs-string\">&quot;synapse-*.json&quot;</span> -mtime +30 -delete\n\n<span class=\"hljs-built_in\">echo</span> <span class=\"hljs-string\">&quot;Backup saved: <span class=\"hljs-variable\">$BACKUP_DIR</span>/synapse-<span class=\"hljs-variable\">$DATE</span>.json&quot;</span></code></pre><p>Aggiunga a crontab:</p>\n<pre><code class=\"hljs language-plaintext\">0 2 * * * /usr/local/bin/backup-synapse.sh</code></pre><h2>Ripristino</h2>\n<h3>Ripristino sulla stessa mente</h3>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Parse backup and re-POST each memory</span>\njq -c <span class=\"hljs-string\">&#x27;.memories[]&#x27;</span> backup.json | <span class=\"hljs-keyword\">while</span> <span class=\"hljs-built_in\">read</span> mem; <span class=\"hljs-keyword\">do</span>\n  curl -X POST https://synapse.schaefer.zone/memory \\\n    -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_MIND_KEY&quot;</span> \\\n    -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n    -d <span class=\"hljs-string\">&quot;<span class=\"hljs-subst\">$(echo <span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">$mem</span>&quot;</span> | jq &#x27;{category, key, content, tags, priority}&#x27;)</span>&quot;</span>\n<span class=\"hljs-keyword\">done</span></code></pre><h3>Ripristino su una nuova mente</h3>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># 1. Create new mind</span>\nNEW_KEY=$(curl -s -X POST https://synapse.schaefer.zone/minds \\\n  -H <span class=\"hljs-string\">&quot;Authorization: Bearer YOUR_JWT&quot;</span> \\\n  -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n  -d <span class=\"hljs-string\">&#x27;{&quot;name&quot;:&quot;Restored Mind&quot;,&quot;description&quot;:&quot;Restore from backup&quot;}&#x27;</span> \\\n  | jq -r .mind_key)\n\n<span class=\"hljs-comment\"># 2. Import memories to new mind</span>\njq -c <span class=\"hljs-string\">&#x27;.memories[]&#x27;</span> backup.json | <span class=\"hljs-keyword\">while</span> <span class=\"hljs-built_in\">read</span> mem; <span class=\"hljs-keyword\">do</span>\n  curl -X POST https://synapse.schaefer.zone/memory \\\n    -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$NEW_KEY</span>&quot;</span> \\\n    -H <span class=\"hljs-string\">&quot;Content-Type: application/json&quot;</span> \\\n    -d <span class=\"hljs-string\">&quot;<span class=\"hljs-subst\">$(echo <span class=\"hljs-string\">&quot;<span class=\"hljs-variable\">$mem</span>&quot;</span> | jq &#x27;{category, key, content, tags, priority}&#x27;)</span>&quot;</span>\n<span class=\"hljs-keyword\">done</span></code></pre><h3>Script di ripristino in Python</h3>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">import</span> json\n<span class=\"hljs-keyword\">import</span> requests\n\nURL = <span class=\"hljs-string\">&quot;https://synapse.schaefer.zone&quot;</span>\nMIND_KEY = <span class=\"hljs-string\">&quot;mk_...&quot;</span>\n\n<span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">restore</span>(<span class=\"hljs-params\">backup_file</span>):\n    <span class=\"hljs-keyword\">with</span> <span class=\"hljs-built_in\">open</span>(backup_file) <span class=\"hljs-keyword\">as</span> f:\n        data = json.load(f)\n    \n    <span class=\"hljs-keyword\">for</span> mem <span class=\"hljs-keyword\">in</span> data[<span class=\"hljs-string\">&quot;memories&quot;</span>]:\n        requests.post(\n            <span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory&quot;</span>,\n            headers={\n                <span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{MIND_KEY}</span>&quot;</span>,\n                <span class=\"hljs-string\">&quot;Content-Type&quot;</span>: <span class=\"hljs-string\">&quot;application/json&quot;</span>\n            },\n            json={\n                <span class=\"hljs-string\">&quot;category&quot;</span>: mem[<span class=\"hljs-string\">&quot;category&quot;</span>],\n                <span class=\"hljs-string\">&quot;key&quot;</span>: mem[<span class=\"hljs-string\">&quot;key&quot;</span>],\n                <span class=\"hljs-string\">&quot;content&quot;</span>: mem[<span class=\"hljs-string\">&quot;content&quot;</span>],\n                <span class=\"hljs-string\">&quot;tags&quot;</span>: mem.get(<span class=\"hljs-string\">&quot;tags&quot;</span>, []),\n                <span class=\"hljs-string\">&quot;priority&quot;</span>: mem.get(<span class=\"hljs-string\">&quot;priority&quot;</span>, <span class=\"hljs-string\">&quot;normal&quot;</span>)\n            }\n        )\n    \n    <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f&quot;Restored <span class=\"hljs-subst\">{<span class=\"hljs-built_in\">len</span>(data[<span class=\"hljs-string\">&#x27;memories&#x27;</span>])}</span> memories&quot;</span>)\n\nrestore(<span class=\"hljs-string\">&quot;backup.json&quot;</span>)</code></pre><h2>Migrazione tra menti</h2>\n<pre><code class=\"hljs language-python\"><span class=\"hljs-keyword\">def</span> <span class=\"hljs-title function_\">migrate_memories</span>(<span class=\"hljs-params\">source_key, target_key</span>):\n    <span class=\"hljs-string\">&quot;&quot;&quot;Migrate all memories from source mind to target mind.&quot;&quot;&quot;</span>\n    <span class=\"hljs-comment\"># Export from source</span>\n    r = requests.get(\n        <span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory/mind-export&quot;</span>,\n        headers={<span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{source_key}</span>&quot;</span>}\n    )\n    data = r.json()\n    \n    <span class=\"hljs-comment\"># Import to target</span>\n    <span class=\"hljs-keyword\">for</span> mem <span class=\"hljs-keyword\">in</span> data[<span class=\"hljs-string\">&quot;memories&quot;</span>]:\n        requests.post(\n            <span class=\"hljs-string\">f&quot;<span class=\"hljs-subst\">{URL}</span>/memory&quot;</span>,\n            headers={\n                <span class=\"hljs-string\">&quot;Authorization&quot;</span>: <span class=\"hljs-string\">f&quot;Bearer <span class=\"hljs-subst\">{target_key}</span>&quot;</span>,\n                <span class=\"hljs-string\">&quot;Content-Type&quot;</span>: <span class=\"hljs-string\">&quot;application/json&quot;</span>\n            },\n            json={\n                <span class=\"hljs-string\">&quot;category&quot;</span>: mem[<span class=\"hljs-string\">&quot;category&quot;</span>],\n                <span class=\"hljs-string\">&quot;key&quot;</span>: mem[<span class=\"hljs-string\">&quot;key&quot;</span>],\n                <span class=\"hljs-string\">&quot;content&quot;</span>: mem[<span class=\"hljs-string\">&quot;content&quot;</span>],\n                <span class=\"hljs-string\">&quot;tags&quot;</span>: mem.get(<span class=\"hljs-string\">&quot;tags&quot;</span>, []),\n                <span class=\"hljs-string\">&quot;priority&quot;</span>: mem.get(<span class=\"hljs-string\">&quot;priority&quot;</span>, <span class=\"hljs-string\">&quot;normal&quot;</span>)\n            }\n        )\n    \n    <span class=\"hljs-built_in\">print</span>(<span class=\"hljs-string\">f&quot;Migrated <span class=\"hljs-subst\">{<span class=\"hljs-built_in\">len</span>(data[<span class=\"hljs-string\">&#x27;memories&#x27;</span>])}</span> memories&quot;</span>)</code></pre><h2>Backup di altri dati</h2>\n<p>Non dimentichi di fare backup di:</p>\n<table>\n<thead>\n<tr>\n<th>Tipo di dato</th>\n<th>Endpoint</th>\n</tr>\n</thead>\n<tbody><tr>\n<td>Memorie</td>\n<td><code>GET /memory/mind-export</code></td>\n</tr>\n<tr>\n<td>Attività</td>\n<td><code>GET /mind/tasks</code></td>\n</tr>\n<tr>\n<td>Script</td>\n<td><code>GET /scripts</code></td>\n</tr>\n<tr>\n<td>Webhook</td>\n<td><code>GET /webhooks</code></td>\n</tr>\n<tr>\n<td>Cron job</td>\n<td><code>GET /cron</code></td>\n</tr>\n<tr>\n<td>Variabili</td>\n<td><code>GET /var</code></td>\n</tr>\n<tr>\n<td>Cronologia chat</td>\n<td><code>GET /chat/history?limit=10000</code></td>\n</tr>\n</tbody></table>\n<h2>Verifica</h2>\n<p>Dopo il ripristino, verifichi:</p>\n<pre><code class=\"hljs language-bash\"><span class=\"hljs-comment\"># Count memories</span>\ncurl -s -H <span class=\"hljs-string\">&quot;Authorization: Bearer <span class=\"hljs-variable\">$KEY</span>&quot;</span> \\\n     https://synapse.schaefer.zone/memory/stats | jq .total\n\n<span class=\"hljs-comment\"># Compare with backup</span>\njq .memory_count backup.json</code></pre><h2>Best practice</h2>\n<div class=\"callout callout-ok\"></div><h2>Prossimi passi</h2>\n<ul>\n<li><a href=\"/docs/api/memory\">Memory API</a></li>\n<li><a href=\"/docs/api/cron\">Cron &amp; Scheduler</a> — per backup automatizzati</li>\n</ul>\n","urls":{"html":"/docs/guides/backup-restore","text":"/docs/guides/backup-restore?format=text","json":"/docs/guides/backup-restore?format=json","llm":"/docs/guides/backup-restore?format=llm"},"translations_available":["en","zh","hi","es","fr","ar","pt","ru","ja","de","it","ko","nl","pl","tr","sv","vi","th","id","uk"]}