longmem export command exports your AI’s memory to JSON or Markdown format for backup, analysis, or migration.
Syntax
Options
| Option | Alias | Description | Default |
|---|---|---|---|
--project <name> | -p | Filter by project name | All projects |
--days <n> | -d | Only include last N days (max: 365) | All time |
--format <fmt> | -f | Output format: json or markdown | json |
--raw | -r | Include raw tool_input/tool_output | false |
--output <file> | -o | Write to file instead of stdout | stdout |
--help | -h | Show help message | - |
Examples
Export Everything to JSON
Export Last 30 Days to Markdown
Export Specific Project
Export with Raw Tool Data
Export to File Directly
Requirements
The daemon must be running to export data. If the daemon is stopped, you’ll see:JSON Format
The default JSON export includes:With --raw Flag
When using --raw, each observation includes full tool_input and tool_output:
Markdown Format
The Markdown format produces a human-readable report:Filtering Options
By Project
Export only memory related to a specific project:project field set during session start.
By Time Range
Limit export to recent memory:Combine Filters
Output Options
Write to stdout (Default)
Write to File Directly
-o, the command prints:
Use Cases
Regular Backups
Generate Weekly Reports
Migrate Between Systems
Analyze Memory
Share Project Context
Error Handling
Daemon Not Running
Invalid Days Value
Connection Timeout
- Use more specific filters (—project, —days)
- Restart daemon to clear any locks
- Check database size:
ls -lh ~/.longmem/longmem.db
No Data to Export
If filters match no data, the export will be empty:Exit Codes
0- Export completed successfully1- Error occurred (daemon not running, invalid options, export failed)
Performance
Export Times
Typical export times:| Database Size | Sessions | Export Time |
|---|---|---|
| <10 MB | <50 | <1s |
| 10-100 MB | 50-500 | 1-5s |
| 100-500 MB | 500-2000 | 5-30s |
| >500 MB | >2000 | 30-60s |
Optimization Tips
-
Use filters to reduce export size:
-
Avoid —raw unless necessary:
-
Export to file instead of piping:
Related Commands
longmem stats- View summary statisticslongmem status- Check daemon statuslongmem start- Start daemon for export