Skip to main content

CLI: Import & Export

Bulk import and export memories with the Trix CLI for backups, data portability, and migrations.

Overview

The export and import commands provide tools for bulk data operations, enabling backups, data portability, and migrations. Export memories to JSON, Markdown, or CSV formats, and import them back to recreate your memory collection.

Import and export operations are ideal for backups, migrating between accounts, and integrating Trix with external tools and workflows.

Export Memories

Export memories to various formats including JSON (with full metadata), Markdown (human-readable), and CSV (spreadsheet-compatible).

Basic Export

# Export all memories to JSON (stdout)
trix export

# Export to file
trix export > backup.json

# Export to markdown
trix export --format markdown --file notes.md

# Export to CSV
trix export --format csv --file memories.csv

Export Formats

FormatDescriptionUse Case
jsonJSON format with full metadata (default)Backups, re-import, API integration
markdown / mdHuman-readable markdown documentsDocumentation, reading, note-taking apps
csvCSV spreadsheet formatExcel, Google Sheets, data analysis

Filtered Export

# Export from specific space
trix export --space work --file work-memories.json

# Export memories with specific tags
trix export --tags important,project --file important.json

# Export recent memories
trix export --since 30d > recent-30days.json
trix export --since 7d --format md > weekly-notes.md

# Export matching a search query
trix export --query "meeting notes" --format json > meetings.json

# Combine filters
trix export --space work --tags project --since 14d > recent-project-work.json

Export Options

OptionDescription
--formatOutput format: json, markdown, csv
--fileOutput file (default: stdout)
--spaceExport only from specific space
--tagsExport only memories with these tags
--sinceExport memories newer than duration (e.g., 30d)
--queryExport memories matching search query

When using --query, the export is limited to 100 results. For bulk exports of large datasets, use the list-based approach without --query.

Import Memories

Import memories from a JSON export file. The import process recreates memories in your account, but original IDs are not preserved (new IDs are generated).

Basic Import

# Import from file
trix import backup.json

# Import from stdin
cat backup.json | trix import -

# Import into specific space
trix import backup.json --space archive

# Add additional tags to all imported memories
trix import backup.json --tags imported,2024

# Preview what would be imported
trix import backup.json --dry-run

# Skip confirmation prompt
trix import backup.json --force

Import Process

The import command:

  1. Reads and parses the JSON export file
  2. Shows a preview of what will be imported
  3. Prompts for confirmation (unless --force is used)
  4. Creates each memory individually
  5. Reports successes and failures
  6. Displays new memory IDs for successful imports

Important notes about import:

  • Original memory IDs are not preserved
  • New IDs are generated for all imported memories
  • Relationships between memories are not preserved
  • Timestamps are not preserved (new creation time is set)

Import Options

OptionDescription
--spaceImport into specific space (overrides original)
--tagsAdd additional tags to all imported memories
--dry-runPreview what would be imported without making changes
--forceSkip confirmation prompt

Common Examples

Complete Backup & Restore

# Create a backup
trix export --file backup-$(date +%Y%m%d).json

# Later, restore from backup
trix import backup-20260115.json --dry-run  # Preview first
trix import backup-20260115.json            # Confirm and import

Migrate Between Spaces

# Export from one space
trix export --space old-project --file old-project.json

# Import into new space
trix import old-project.json --space new-project --tags migrated

Selective Export & Import

# Export only important tagged memories
trix export --tags important,critical --file important-backup.json

# Export recent work memories
trix export --space work --since 7d --file recent-work.json

# Import and add archive tag
trix import old-memories.json --tags archived,legacy

Export to Markdown for Reading

# Export all memories as markdown
trix export --format markdown --file all-memories.md

# Export specific category
trix export --tags meeting-notes --format md --file meetings.md

# Export recent notes
trix export --since 14d --format markdown > recent-notes.md

Export to CSV for Analysis

# Export to CSV
trix export --format csv --file memories.csv

# Open in spreadsheet application
# Use for data analysis, reporting, or importing to other tools

Scheduled Backups

#!/bin/bash
# backup-trix.sh - Run daily via cron

BACKUP_DIR="$HOME/backups/trix"
DATE=$(date +%Y%m%d)
mkdir -p "$BACKUP_DIR"

# Create daily backup
trix export --file "$BACKUP_DIR/trix-backup-$DATE.json"

# Keep only last 30 days of backups
find "$BACKUP_DIR" -name "trix-backup-*.json" -mtime +30 -delete

echo "Backup completed: trix-backup-$DATE.json"

# Add to crontab:
# 0 2 * * * /path/to/backup-trix.sh

Migrate Between Accounts

# Export from old account
trix export --file full-export.json

# Switch to new account
trix auth logout
trix auth login --email [email protected]

# Import to new account
trix import full-export.json --tags migrated-from-old-account

Data Portability

JSON Export Structure

The JSON export includes all memory metadata, making it suitable for backups and programmatic processing:

{
  "exported_at": "2026-01-15T10:30:00Z",
  "version": "1.0",
  "count": 3,
  "memories": [
    {
      "id": "<memory-uuid>",
      "content": "Memory content here",
      "space_id": "<space-uuid>",
      "is_private": false,
      "tags": ["important", "work"],
      "priority": 5,
      "metadata": {
        "source": "cli",
        "custom_field": "value"
      },
      "created_at": "2026-01-10T15:20:00Z",
      "updated_at": "2026-01-12T09:15:00Z"
    }
  ]
}

External Tool Integration

The export formats enable integration with various tools:

  • JSON: API integration, custom processing, backups
  • Markdown: Obsidian, Notion, Bear, other note-taking apps
  • CSV: Excel, Google Sheets, data analysis tools
# Process exported JSON with jq
trix export -o json | jq '.memories[] | select(.tags | contains(["important"]))'

# Convert to CSV and analyze in Excel
trix export --format csv --file data.csv
# Open data.csv in Excel for pivot tables, charts, etc.

# Export to markdown and import to Obsidian
trix export --format markdown --file obsidian-import.md
# Copy to Obsidian vault

Best Practices

Backup Strategy

  • Schedule regular automated backups (daily or weekly)
  • Store backups in multiple locations (local, cloud)
  • Test restore process periodically
  • Keep backups for a retention period (30-90 days)
  • Use compressed storage for backup files

Import Safety

  • Always use --dry-run before importing large datasets
  • Import into a test space first to verify data
  • Use tags to identify imported memories (--tags imported)
  • Monitor import progress for failures
  • Keep the original export file until import is verified

Performance

  • Large exports (10,000+ memories) may take several minutes
  • Imports are rate-limited to prevent API abuse
  • Break very large imports into smaller batches
  • Use --query for targeted exports (limited to 100 results)

Command Reference

export Command

trix export [OPTIONS]

Export memories to JSON, Markdown, or CSV format.

Options:
  -f, --format FORMAT    Output format: json, markdown, csv (default: json)
      --file FILE        Write to file instead of stdout
  -s, --space SPACE      Export from specific space
  -t, --tags TAGS        Export memories with these tags (comma-separated)
      --since DURATION   Export memories newer than duration (e.g., 30d)
      --query QUERY      Export memories matching search query (limit 100)

import Command

trix import [FILE] [OPTIONS]

Import memories from a JSON export file.

Arguments:
  FILE                   Path to import file, or '-' for stdin

Options:
  -s, --space SPACE      Import into specific space (overrides original)
  -t, --tags TAGS        Add tags to all imported memories (comma-separated)
      --dry-run          Preview without importing
  -f, --force            Skip confirmation prompt

Next Steps