Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vltansky/1da9d41a8f123e65b8f719cd1867960d to your computer and use it in GitHub Desktop.
Save vltansky/1da9d41a8f123e65b8f719cd1867960d to your computer and use it in GitHub Desktop.
# Moving Cursor Chat History Between Computers
## Overview
This guide explains how to transfer your complete Cursor chat history from one computer to another. Cursor stores all conversations in a SQLite database that can be backed up and restored.
## Prerequisites
- Administrative access on both computers
- Cursor installed on the destination computer
- Sufficient storage space (database can be ~1.5GB or larger)
- Basic command line knowledge
## Step-by-Step Transfer Process
### Step 1: Prepare Source Computer
#### 1.1 Close Cursor Completely
```bash
# Ensure Cursor is fully closed (not just minimized)
# Check Activity Monitor (macOS) or Task Manager (Windows) if needed
```
#### 1.2 Locate the Database
**macOS**: `~/Library/Application Support/Cursor/User/globalStorage/state.vscdb`
**Windows**: `%APPDATA%\Cursor\User\globalStorage\state.vscdb`
**Linux**: `~/.config/Cursor/User/globalStorage/state.vscdb`
#### 1.3 Verify Database Integrity
```bash
# macOS/Linux
sqlite3 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb "PRAGMA integrity_check;"
# Should return: ok
```
### Step 2: Create Backup
#### 2.1 Create Full Database Backup
```bash
# macOS
cp ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb ~/Desktop/cursor-chats-backup.db
# Windows (PowerShell)
Copy-Item "$env:APPDATA\Cursor\User\globalStorage\state.vscdb" "$env:USERPROFILE\Desktop\cursor-chats-backup.db"
# Linux
cp ~/.config/Cursor/User/globalStorage/state.vscdb ~/Desktop/cursor-chats-backup.db
```
#### 2.2 Verify Backup
```bash
# Check file size and integrity
ls -la ~/Desktop/cursor-chats-backup.db
sqlite3 ~/Desktop/cursor-chats-backup.db "SELECT COUNT(*) FROM cursorDiskKV WHERE key LIKE 'composerData:%';"
```
#### 2.3 Export Conversation List (Optional)
```bash
# Create a list of all conversations for verification
sqlite3 ~/Desktop/cursor-chats-backup.db \
"SELECT key, length(value) FROM cursorDiskKV WHERE key LIKE 'composerData:%' ORDER BY ROWID DESC;" > ~/Desktop/conversation-inventory.txt
```
### Step 3: Transfer Files
#### 3.1 Transfer Methods
**Option A: Cloud Storage**
```bash
# Upload to cloud service (Google Drive, Dropbox, etc.)
# Recommended for large files
```
**Option B: External Drive**
```bash
# Copy to USB drive or external storage
cp ~/Desktop/cursor-chats-backup.db /Volumes/USB_DRIVE/
```
**Option C: Network Transfer**
```bash
# Using scp (if both computers are on same network)
scp ~/Desktop/cursor-chats-backup.db user@destination-computer:~/Desktop/
```
**Option D: Email/File Sharing**
```bash
# Only for smaller databases (< 25MB typically)
# Most email providers have attachment size limits
```
### Step 4: Prepare Destination Computer
#### 4.1 Install Cursor
- Download and install Cursor on the destination computer
- Launch Cursor at least once to create the directory structure
- Close Cursor completely
#### 4.2 Verify Directory Structure
```bash
# macOS
ls -la ~/Library/Application\ Support/Cursor/User/globalStorage/
# Windows
dir "%APPDATA%\Cursor\User\globalStorage\"
# Linux
ls -la ~/.config/Cursor/User/globalStorage/
```
### Step 5: Restore Chat History
#### 5.1 Backup Existing Database (if any)
```bash
# macOS
mv ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb.old
# Windows
move "%APPDATA%\Cursor\User\globalStorage\state.vscdb" "%APPDATA%\Cursor\User\globalStorage\state.vscdb.old"
# Linux
mv ~/.config/Cursor/User/globalStorage/state.vscdb ~/.config/Cursor/User/globalStorage/state.vscdb.old
```
#### 5.2 Copy Transferred Database
```bash
# macOS
cp ~/Desktop/cursor-chats-backup.db ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb
# Windows
copy "%USERPROFILE%\Desktop\cursor-chats-backup.db" "%APPDATA%\Cursor\User\globalStorage\state.vscdb"
# Linux
cp ~/Desktop/cursor-chats-backup.db ~/.config/Cursor/User/globalStorage/state.vscdb
```
#### 5.3 Set Proper Permissions
```bash
# macOS/Linux
chmod 644 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb
# Windows (usually not needed, but if issues occur)
# Right-click file → Properties → Security → Edit permissions
```
### Step 6: Verification
#### 6.1 Test Database Integrity
```bash
# macOS
sqlite3 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb "PRAGMA integrity_check;"
```
#### 6.2 Count Conversations
```bash
# Verify conversation count matches source
sqlite3 ~/Library/Application\ Support/Cursor/User/globalStorage/state.vscdb \
"SELECT COUNT(*) FROM cursorDiskKV WHERE key LIKE 'composerData:%';"
```
#### 6.3 Launch Cursor
1. Start Cursor
2. Open chat history
3. Verify recent conversations are visible
4. Test that you can access older conversations
## Advanced Options
### Selective Transfer (Partial History)
If you only want recent conversations:
```bash
# Export only recent conversations (last 100)
sqlite3 source_state.vscdb "
CREATE TABLE temp_recent AS
SELECT * FROM cursorDiskKV
WHERE key LIKE 'composerData:%'
ORDER BY ROWID DESC LIMIT 100;
CREATE TABLE temp_bubbles AS
SELECT * FROM cursorDiskKV
WHERE key LIKE 'bubbleId:%';
.output recent_chats.sql
.dump temp_recent
.dump temp_bubbles
"
```
### Merging Chat Histories
⚠️ **Advanced Users Only** - Risk of data corruption
```bash
# This requires careful handling of UUID conflicts
# Consider using professional database tools
# Always backup before attempting
```
## Troubleshooting
### Common Issues
#### Database Locked Error
```bash
# Solution: Ensure Cursor is completely closed
ps aux | grep -i cursor # Check for running processes
killall Cursor # Force close if needed (macOS/Linux)
```
#### File Not Found
```bash
# Verify Cursor has been launched at least once on destination
# Check correct path for your operating system
# Manually create directory if needed:
mkdir -p ~/Library/Application\ Support/Cursor/User/globalStorage/
```
#### Conversations Not Appearing
1. Check database integrity: `PRAGMA integrity_check;`
2. Verify file permissions
3. Restart Cursor completely
4. Check Cursor logs for errors
#### Large File Transfer Issues
```bash
# Split large databases (advanced)
# Use compression:
gzip cursor-chats-backup.db
# Transfer compressed file
gunzip cursor-chats-backup.db.gz
```
### Verification Queries
#### Check Recent Conversations
```sql
SELECT key FROM cursorDiskKV
WHERE key LIKE 'composerData:%' AND length(value) > 5000
ORDER BY ROWID DESC LIMIT 10;
```
#### Verify Message Content
```sql
-- Replace UUID with actual conversation ID
SELECT substr(value, 1, 200) FROM cursorDiskKV
WHERE key = 'composerData:YOUR_UUID_HERE';
```
## Important Warnings
⚠️ **Critical Warnings:**
- Always close Cursor completely before database operations
- Create backups before any modifications
- Database contains sensitive conversation data - handle securely
- File paths are case-sensitive on macOS/Linux
- Large databases may take time to transfer and load
💡 **Best Practices:**
- Test the transfer with a small backup first
- Keep the original database until transfer is verified
- Document your conversation count for verification
- Consider regular backups for future transfers
- Use secure transfer methods for sensitive data
## Platform-Specific Notes
### macOS
- Use `~/Library/Application Support/` (note the space)
- May need to show hidden files in Finder
- Use `Command + Shift + G` to navigate to hidden folders
### Windows
- Use `%APPDATA%` environment variable
- Path separators are backslashes (`\`)
- May need to enable "Show hidden files"
### Linux
- Hidden directories start with `.`
- Use `ls -la` to see hidden files
- Check distribution-specific paths if standard path doesn't exist
## Recovery Options
If something goes wrong:
1. **Restore Original Database:**
```bash
mv state.vscdb.old state.vscdb
```
2. **Fresh Start:**
```bash
rm state.vscdb
# Launch Cursor to create new database
```
3. **Partial Recovery:**
```bash
# Extract specific conversations from backup
sqlite3 backup.db "SELECT value FROM cursorDiskKV WHERE key = 'composerData:UUID';"
```
---
*This guide covers the complete process of transferring Cursor chat history between computers. Always prioritize data safety and create backups before making any changes.*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment