This guide explains how to backup and restore your AI Memory Qdrant database.
- 3 Collections:
discussions,conventions,code-patterns - Configuration files:
settings.json,.env(from install directory) - Optional: Log files (with
--include-logsflag)
Backups are stored in <repo>/backups/ by default:
ai-memory/
└── backups/
└── 2026-02-03_143052/
├── qdrant/
│ ├── discussions.snapshot
│ ├── conventions.snapshot
│ └── code-patterns.snapshot
├── config/
│ ├── settings.json
│ └── .env
└── manifest.json
This location is inside the repository directory (not the install directory), so backups survive reinstallation.
Each backup includes a manifest.json for verification:
{
"backup_date": "2026-02-03T14:30:52.123456+00:00",
"ai_memory_version": "2.0.2",
"qdrant_host": "localhost",
"qdrant_port": 26350,
"collections": {
"discussions": {
"name": "discussions",
"records": 42,
"snapshot_file": "discussions.snapshot",
"size_bytes": 1048576
}
},
"config_files": ["settings.json", ".env"],
"includes_logs": false
}- Docker services running (Qdrant must be accessible)
- Python 3.10+
- httpx library (not included in base requirements)
cd /path/to/ai-memory # Where you cloned the repopython3 -m venv .venv
source .venv/bin/activate # Linux/macOS
# OR
.venv\Scripts\activate # Windowspip install httpxFind the key in your installation's .env file:
cat ~/.ai-memory/docker/.env | grep QDRANT_API_KEYCopy the value after the = sign (e.g., QDRANT_API_KEY=abc123...).
export QDRANT_API_KEY="your-key-here"python scripts/backup_qdrant.pypython scripts/backup_qdrant.py --output /custom/pathpython scripts/backup_qdrant.py --include-logs============================================================
AI Memory Backup
============================================================
Backup directory: /path/to/ai-memory/backups/2026-02-03_143052
Qdrant: localhost:26350
Checking disk space...
✓ 50.2 GB available
Backing up discussions...
✓ 42 records, snapshot created (1.2 MB)
Backing up conventions...
✓ 15 records, snapshot created (512.0 KB)
Backing up code-patterns...
✓ 8 records, snapshot created (256.0 KB)
Backing up config files...
✓ settings.json
✓ .env
============================================================
✓ Backup complete: /path/to/ai-memory/backups/2026-02-03_143052
Total size: 2.0 MB
Collections: 3
Records: 65
============================================================
| Directory | Contents |
|---|---|
qdrant/ |
Collection snapshots (.snapshot files) |
config/ |
Settings and .env backup |
logs/ |
Log files (if --include-logs used) |
manifest.json |
Backup metadata for verification |
python scripts/restore_qdrant.py backups/2026-02-03_143052python scripts/restore_qdrant.py backups/2026-02-03_143052 --forcepython scripts/restore_qdrant.py backups/2026-02-03_143052 --restore-configpython scripts/restore_qdrant.py backups/2026-02-03_143052 --restore-config --force============================================================
AI Memory Restore
============================================================
Backup: /path/to/ai-memory/backups/2026-02-03_143052
Verifying backup...
✓ manifest.json valid
Backup date: 2026-02-03 14:30:52
Version: 2.0.2
✓ discussions.snapshot (1.2 MB)
✓ conventions.snapshot (512.0 KB)
✓ code-patterns.snapshot (256.0 KB)
Connecting to Qdrant (localhost:26350)...
✓ Connected
Restoring collections...
Restoring discussions (42 records)...
✓ Snapshot uploaded
✓ Collection recovered
Restoring conventions (15 records)...
✓ Snapshot uploaded
✓ Collection recovered
Restoring code-patterns (8 records)...
✓ Snapshot uploaded
✓ Collection recovered
============================================================
✓ Restore complete
Collections restored: 3
Total records: 65
============================================================
-
Check the backup directory exists:
ls -la backups/
-
Verify manifest.json is present and valid:
cat backups/2026-02-03_143052/manifest.json | python -m json.tool -
Verify all snapshot files exist:
ls -la backups/2026-02-03_143052/qdrant/
-
Check collection health via Qdrant API:
curl -H "api-key: $QDRANT_API_KEY" http://localhost:26350/collections -
Verify record counts match manifest:
curl -H "api-key: $QDRANT_API_KEY" http://localhost:26350/collections/discussions -
Test memory retrieval:
/aim-status
Cause: QDRANT_API_KEY not set or incorrect.
Solution:
# Get the correct key from your installation
cat ~/.ai-memory/docker/.env | grep QDRANT_API_KEY
# Export it
export QDRANT_API_KEY="your-key-here"Cause: Docker services not running.
Solution:
cd ~/.ai-memory/docker && docker compose up -dCause: Large collections taking too long to upload.
Solution: The default timeout is 5 minutes (SNAPSHOT_UPLOAD_TIMEOUT=300). For very large collections, you may need to modify the script or split the restore.
Cause: Not enough space for backup files.
Solution: The backup script requires 2x the estimated backup size as safety margin. Free up disk space or specify a different output directory on a larger volume.
Cause: Required dependency not installed.
Solution:
pip install httpxIf a restore fails mid-way, the script automatically rolls back any collections that were already restored. This prevents partial restore states.
-
Backup before major upgrades
python scripts/backup_qdrant.py ./scripts/upgrade.sh
-
Store backups off-machine periodically
rsync -av backups/ backup-server:/ai-memory-backups/
-
Test restore procedure on fresh install
- Spin up a test environment
- Run restore with
--force - Verify data integrity
-
Automate backups (optional)
# Add to crontab for daily backups 0 2 * * * cd /path/to/ai-memory && .venv/bin/python scripts/backup_qdrant.py
-
Rotate old backups
# Keep last 7 days of backups find backups/ -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Qdrant connection failed |
| 2 | Collection backup failed |
| 3 | Insufficient disk space / Qdrant connection failed (restore) |
| 4 | Config backup failed / Collection restore failed |
| Variable | Default | Description |
|---|---|---|
QDRANT_HOST |
localhost |
Qdrant server hostname |
QDRANT_PORT |
26350 |
Qdrant external port |
QDRANT_API_KEY |
(none) | API key for Qdrant authentication |
AI_MEMORY_BACKUP_DIR |
<repo>/backups |
Default backup directory |
AI_MEMORY_INSTALL_DIR |
~/.ai-memory |
Installation directory |