# Computer Reset - Impact Analysis & Recovery Guide

*Generated: 2026-01-19*

---

## 🔴 **What Will Be Lost on Reset**

These items are **NOT** preserved by a standard macOS reset and must be restored:

| Category | Item | Impact |
|----------|------|--------|
| **Cron Jobs** | All crontab entries | ❌ **LOST** - Must restore |
| **Launchd Services** | LaunchAgent plist files | ❌ **LOST** - Must restore |
| **PostgreSQL Data** | Database contents | ❌ **LOST** - Must restore |
| **Homebrew Services** | Running services | ❌ **LOST** - Must restart |
| **System Settings** | User preferences, configs | ❌ **LOST** - May need reconfiguration |

---

## 🟡 **What Should Survive Reset**

These items **should** survive if you preserve your user data during reset:

| Category | Item | Path | Status |
|----------|------|------|--------|
| **Project Files** | Remix Sniper code | `~/projects/remix-sniper/` | ⚠️ Check |
| **Tracking Data** | JSON tracking files | `~/.remix-sniper/tracking/` | ⚠️ Check |
| **Workspace** | Clawdbot workspace | `~/.clawdbot/workspace/` | ⚠️ Check |
| **Scripts** | Custom shell scripts | `~/.clawdbot/workspace/*.sh` | ⚠️ Check |
| **Documentation** | MD files, notes | `~/.clawdbot/workspace/*.md` | ⚠️ Check |

**Note:** "Check" means verify after reset - some resets wipe user data, some preserve it.

---

## ✅ **What's At Risk Right Now**

### 1. **Cron Jobs (6 jobs)**
```bash
# Daily text to Jake Smith at 9:10 PM EST
10 21 * * * /opt/homebrew/bin/imsg send --to "Jake Smith" --text "Helllllo"

# Daily anus fact at 9am EST
0 9 * * * /Users/jakeshore/.clawdbot/workspace/daily-anus-fact.sh

# Daily pickle motivation to Stevan Woska at 5:45 PM EST
45 17 * * * /Users/jakeshore/.clawdbot/workspace/pickle_motivation.sh +15167611826

# Daily remix sniper scan at 9am EST
0 9 * * * cd ~/projects/remix-sniper && /Users/jakeshore/projects/remix-sniper/venv/bin/python scripts/daily_scan.py >> ~/projects/remix-sniper/daily_scan.log 2>&1

# Weekly remix stats update (Sundays at 10am)
0 10 * * 0 cd ~/projects/remix-sniper && /Users/jakeshore/projects/remix-sniper/venv/bin/python scripts/update_remix_stats.py >> ~/projects/remix-sniper/stats_update.log 2>&1

# Weekly validation report (Sundays at 11am)
0 11 * * 0 cd ~/projects/remix-sniper && /Users/jakeshore/projects/remix-sniper/venv/bin/python scripts/weekly_report.py >> ~/projects/remix-sniper/weekly_report.log 2>&1
```

### 2. **Launchd Service**
```bash
# Remi bot auto-restart service
~/Library/LaunchAgents/com.jakeshore.remix-sniper.plist
```

### 3. **PostgreSQL Database**
```
Database: remix_sniper
Tables: songs, song_metrics, opportunities, user_preferences
Current data: Empty (0 rows) - but schema exists
```

### 4. **Tracking Data (Important!)**
```
~/.remix-sniper/tracking/predictions.json    (8 predictions)
~/.remix-sniper/tracking/remixes.json        (1 remix outcome)
~/.remix-sniper/tracking/snapshots/          (daily chart snapshots)
```

### 5. **Environment Variables**
```
~/projects/remix-sniper/.env
  - DISCORD_BOT_TOKEN
  - DATABASE_URL
```

---

## 🛡️ **Backup & Restore System**

### Quick Start

Run these commands **before** your reset:

```bash
# 1. Run backup
~/.clawdbot/workspace/backup_before_reset.sh

# 2. Copy backup to external storage
rsync -av ~/.clawdbot/workspace/backup-before-reset-* /Volumes/ExternalDrive/

# 3. Note the backup directory name (e.g., backup-before-reset-20260119-120000)
```

After reset:

```bash
# 1. Copy backup from external storage
rsync -av /Volumes/ExternalDrive/backup-before-reset-* ~/.clawdbot/workspace/

# 2. Run restore
~/.clawdbot/workspace/restore_after_reset.sh ~/.clawdbot/workspace/backup-before-reset-YYYYMMDD-HHMMSS

# 3. Verify everything works
crontab -l                          # Check cron jobs
launchctl list | grep remix-sniper   # Check launchd
psql -d remix_sniper -c '\l'         # Check database
```

---

## 📋 **Detailed Backup Process**

### What Gets Backed Up

| Item | What's Backed Up | Location in Backup |
|------|-----------------|-------------------|
| Crontab | All cron jobs | `crontab-backup.txt` |
| Launchd | plist files | `launchd/` |
| PostgreSQL | Full database dump | `remix_sniper-db.sql` |
| Tracking Data | JSON files, snapshots | `remix-sniper/` |
| Environment | .env files | `env-files/` |
| Workspace | All workspace files | `clawdbot-workspace/` |
| Scripts | Shell scripts | `scripts/` |
| Checksums | SHA256 hashes | `sha256-checksums.txt` |

### Backup Script Details

```bash
# Location
~/.clawdbot/workspace/backup_before_reset.sh

# Creates backup at
~/.clawdbot/workspace/backup-before-reset-YYYYMMDD-HHMMSS/

# Backs up:
#   1. Crontab entries
#   2. Launchd plist files
#   3. PostgreSQL database dump
#   4. Remix Sniper tracking data
#   5. Environment files (.env)
#   6. Clawdbot workspace
#   7. Custom scripts
```

### Restore Script Details

```bash
# Location
~/.clawdbot/workspace/restore_after_reset.sh

# Usage
~/.clawdbot/workspace/restore_after_reset.sh <backup-directory>

# Restores:
#   1. Crontab entries
#   2. Launchd services (and loads them)
#   3. PostgreSQL database (if psql installed)
#   4. Remix Sniper tracking data
#   5. Environment files
#   6. Clawdbot workspace
#   7. Custom scripts
```

---

## 🔧 **Post-Restore Checklist**

After running the restore script, verify these items:

### 1. **Cron Jobs**
```bash
crontab -l
# Expected: 6 jobs listed above
```

### 2. **Launchd Service**
```bash
launchctl list | grep remix-sniper
# Expected: com.jakeshore.remix-sniper
```

### 3. **PostgreSQL**
```bash
brew services list | grep postgresql
# Expected: postgresql@16 (started)

psql -d remix_sniper -c "\dt"
# Expected: 4 tables (songs, song_metrics, opportunities, user_preferences)
```

### 4. **Tracking Data**
```bash
ls -la ~/.remix-sniper/tracking/
# Expected: predictions.json, remixes.json, snapshots/
```

### 5. **Remix Sniper Bot**
```bash
# Check if bot is running
launchctl list | grep remix-sniper

# Check logs
tail -f ~/projects/remix-sniper/bot.log
```

### 6. **Environment Variables**
```bash
cat ~/projects/remix-sniper/.env
# Expected: DISCORD_BOT_TOKEN, DATABASE_URL set
```

---

## ⚠️ **If Something Goes Wrong**

### Cron jobs not restored
```bash
# Manually restore
crontab ~/.clawdbot/workspace/backup-before-reset-YYYYMMDD-HHMMSS/crontab-backup.txt
```

### Launchd service not loading
```bash
# Check file exists
ls -la ~/Library/LaunchAgents/com.jakeshore.remix-sniper.plist

# Load manually
launchctl load -w ~/Library/LaunchAgents/com.jakeshore.remix-sniper.plist

# Restart manually
launchctl restart com.jakeshore.remix-sniper
```

### PostgreSQL not restored
```bash
# Ensure PostgreSQL is installed and running
brew services start postgresql@16

# Restore manually
psql -d remix_sniper < ~/.clawdbot/workspace/backup-before-reset-YYYYMMDD-HHMMSS/remix_sniper-db.sql
```

### Tracking data not restored
```bash
# Manually copy
cp -R ~/.clawdbot/workspace/backup-before-reset-YYYYMMDD-HHMMSS/remix-sniper/* ~/.remix-sniper/
```

---

## 💾 **Alternative: Cloud Backup**

For extra safety, consider:

1. **GitHub** - Push project code
2. **Dropbox/Google Drive** - Sync workspace and tracking data
3. **Time Machine** - Automatic backup (if not resetting from it)

### Example: Push to GitHub

```bash
cd ~/projects/remix-sniper
git init
git add .
git commit -m "Backup before reset"
git remote add origin <your-repo>
git push -u origin main
```

---

## 📊 **Summary: What's At Risk**

| Risk Level | Item | Backup Available? |
|------------|------|-------------------|
| 🔴 **CRITICAL** | Tracking data (predictions, remixes) | ✅ Yes |
| 🔴 **CRITICAL** | Cron jobs (6 automated tasks) | ✅ Yes |
| 🟡 **HIGH** | Launchd service (bot auto-restart) | ✅ Yes |
| 🟡 **HIGH** | Database schema | ✅ Yes |
| 🟢 **MEDIUM** | Environment variables | ✅ Yes |
| 🟢 **LOW** | Project code (should survive) | ✅ Yes |
| 🟢 **LOW** | Workspace files (should survive) | ✅ Yes |

---

## 🚀 **Before Reseting**

1. **Run backup script**
   ```bash
   ~/.clawdbot/workspace/backup_before_reset.sh
   ```

2. **Copy backup to external storage**
   ```bash
   rsync -av ~/.clawdbot/workspace/backup-before-reset-* /Volumes/ExternalDrive/
   ```

3. **Note the backup directory name**

4. **Test restore (optional)**
   ```bash
   # In a temporary directory
   mkdir -p /tmp/test-restore
   cp -R ~/.clawdbot/workspace/backup-before-reset-* /tmp/test-restore/
   # Verify contents look correct
   ```

---

## 📝 **After Reseting**

1. **Copy backup from external storage**
2. **Run restore script**
3. **Run post-restore checklist**
4. **Test Remi bot in Discord**
5. **Verify daily scan will run tomorrow at 9am**

---

## ❓ **Questions?**

- **What if I lose the backup?** → Reconstruct from notes in `remix-sniper-skill.md`
- **Can I skip some items?** → Yes, but tracking data and cron jobs are critical
- **How long does backup take?** → Usually < 1 minute
- **How long does restore take?** → Usually < 2 minutes

---

## 💛 **Need Help?**

If anything goes wrong:
1. Check the backup directory contents
2. Verify checksums with `shasum -c sha256-checksums.txt`
3. Manually restore specific items if script fails
4. Tag Buba in Discord if stuck
