# Data Export & Backup

> Export your training data, back up your progress, and sync across devices with cloud storage.

Braking Lab stores your training data locally and in the cloud (for registered users). This guide covers how to export, backup, and manage your data to ensure you never lose your progress.

## Storage Architecture

### How Data Is Stored

Braking Lab uses a hybrid storage model:

| Storage Type | What's Stored | Capacity |
|--------------|---------------|----------|
| localStorage | Settings, preferences, calibration | ~10MB |
| IndexedDB | Lap telemetry, custom exercises | 1GB+ |
| Cloud (Supabase) | Synced data for registered users | Unlimited |

### Guest vs. Registered Users

**Guest Users**
- All data stored locally in browser
- Data persists until browser cache cleared
- No sync between devices
- Export for manual backup recommended

**Registered Users**
- Local storage plus cloud sync
- Automatic backup to Supabase
- Sync across multiple devices
- Recoverable if local data is lost

## Exporting Data

### Full Data Export

Export all your training data:

1. Go to **Settings > Data Management**
2. Click **Export All Data**
3. Choose export format (JSON)
4. Download the backup file
5. Store in a safe location

### What Gets Exported

The export includes:

- **Session history** - All your training sessions and scores
- **Custom exercises** - Exercises you've created (up to 50)
- **Lap data** - Imported telemetry and braking zones
- **Settings** - Your preferences and calibration
- **Notes** - Track notes and braking zone notes
- **Progress data** - Your improvement metrics

### Selective Export

Export specific data types:

**Sessions Only**
- Training session history
- Scores and statistics
- Smaller file size

**Exercises Only**
- Custom exercises you've created
- Exercise configurations

**Laps Only**
- Imported lap telemetry
- Braking zone data
- Largest portion of data

### Export Format

Exports are in JSON format:

- Human-readable structure
- Compatible with data tools
- Can be modified if needed
- Includes metadata for validation

## Importing Data

### Restoring from Backup

Restore your data from an export:

1. Go to **Settings > Data Management**
2. Click **Import Data**
3. Select your backup file
4. Choose what to import
5. Confirm import

### Import Options

Configure how data is imported:

| Option | Description |
|--------|-------------|
| Replace All | Delete existing data and import |
| Merge | Add imported data to existing |
| Skip Duplicates | Only import new items |

### Data Validation

During import:

- File format is validated
- Data integrity is checked
- Incompatible data is skipped
- Report shows what was imported

## Cloud Sync

### Enabling Cloud Sync

For registered users:

1. Sign in to your account
2. Go to **Settings > Sync**
3. Enable **Cloud Sync**
4. Choose what to sync

### Sync Settings

Configure sync behavior:

- **Auto-sync** - Sync automatically in background
- **Manual sync** - Only sync when you trigger it
- **Sync frequency** - How often to check for changes
- **Conflict resolution** - How to handle conflicts

### What Syncs

Cloud sync includes:

- Session history
- Custom exercises
- Track notes
- Progress data
- Settings and preferences

**Note:** Lap telemetry is NOT synced to cloud due to size. Use manual export for lap data backup.

### Sync Status

View sync status:

- **Last sync time** shown in Settings
- **Sync indicator** in the app header
- **Pending changes** count displayed
- **Error notifications** if sync fails

## Managing Storage

### Viewing Storage Usage

Check how much data you're using:

1. Go to **Settings > Data Management**
2. View **Storage Usage** section
3. See breakdown by data type
4. Compare to available storage

### Storage Breakdown

| Data Type | Typical Size |
|-----------|--------------|
| Settings | < 1 MB |
| Sessions | 10-50 MB |
| Custom Exercises | 5-20 MB |
| Lap Telemetry | 500 MB - 1 GB |
| Notes | 1-5 MB |

### Clearing Data

Free up space by removing old data:

**Clear Cache**
- Removes temporary data
- Doesn't affect your saved data
- Frees minimal space

**Delete Old Sessions**
- Remove sessions older than X days
- Keeps your best sessions
- Significant space savings

**Delete Laps**
- Remove individual lap files
- Largest space savings
- Cannot be recovered

### Storage Limits

Browser storage limits:

- **Chrome/Edge** - Typically 60% of free disk space
- **Firefox** - Up to 2GB per origin
- **Safari** - Limited, data may be purged after 7 days of inactivity

## Data Privacy

### What Data Is Stored

Braking Lab stores:

- Your training sessions and scores
- Custom exercises you create
- Imported telemetry data
- App settings and preferences
- Account information (if registered)

### What We Don't Store

- Your iRacing credentials (only OAuth tokens)
- Payment information (handled by payment provider)
- Personal driving data beyond what you import

### Data Ownership

Your data belongs to you:

- Export anytime
- Delete anytime
- We don't sell or share your data
- Cloud data encrypted at rest

### Deleting Your Account

To permanently delete your account:

1. Go to **Settings > Account**
2. Click **Delete Account**
3. Export your data first (recommended)
4. Confirm deletion
5. 30-day recovery window
6. Data permanently deleted after

## Backup Best Practices

### Regular Backups

Recommended backup schedule:

- **Weekly** - Export if actively training
- **Before updates** - Export before major app updates
- **Before device changes** - Export before changing browsers/computers
- **After milestones** - Export after achieving goals

### Backup Storage

Where to keep your backups:

- Cloud storage (Google Drive, iCloud, Dropbox)
- External hard drive
- Multiple locations for redundancy
- Avoid storing only on the same computer

### Backup Naming

Use clear file names:

```
brakinglab-backup-2024-01-15.json
brakinglab-backup-2024-01-15-sessions-only.json
```

## Troubleshooting

### Lost Data

If data appears missing:

1. Check if you're signed in (for cloud sync)
2. Check browser storage settings
3. Try a different browser
4. Restore from backup if available

### Import Fails

If import doesn't work:

- Verify file format is correct JSON
- Check file isn't corrupted
- Try importing smaller portions
- Contact support if issues persist

### Sync Issues

If cloud sync isn't working:

1. Check internet connection
2. Sign out and sign back in
3. Check sync settings
4. Try manual sync
5. Contact support if persistent

### Browser Storage Cleared

If browser cleared storage:

- Guest user data cannot be recovered
- Registered users can re-sync from cloud
- Future: Export regularly to prevent loss

---

## Third-Party Services Disclaimer

iRacing® is a third-party service not affiliated with Braking Lab. Braking Lab is not responsible for its availability, functionality, or any changes to the service. All trademarks and rights belong to iRacing.com Motorsport Simulations, LLC.
