File size: 5,204 Bytes
fd382c9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/bash

# Elizabeth Xet Data Preparation Script
# Prepares all data for Xet push - can be manually uploaded if CLI not available

echo "=== Preparing Elizabeth Data for Xet Push ==="

# Create backup directory structure
BACKUP_DIR="/workspace/elizabeth_xet_ready"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
XET_READY_DIR="$BACKUP_DIR/elizabeth_data_$TIMESTAMP"

mkdir -p "$XET_READY_DIR"
echo "Created Xet ready directory: $XET_READY_DIR"

# 1. Database Files
echo "1. Backing up database files..."
mkdir -p "$XET_READY_DIR/databases"

# SQLite databases
if [ -f "/workspace/elizabeth_memory.db" ]; then
    cp "/workspace/elizabeth_memory.db" "$XET_READY_DIR/databases/"
    echo "  ✓ elizabeth_memory.db"
fi

if [ -f "/workspace/nova_memory.db" ]; then
    cp "/workspace/nova_memory.db" "$XET_READY_DIR/databases/"
    echo "  ✓ nova_memory.db"
fi

# 2. ChromaDB Data
echo "2. Backing up ChromaDB data..."
if [ -d "/workspace/elizabeth_chroma" ]; then
    mkdir -p "$XET_READY_DIR/chromadb"
    cp -r "/workspace/elizabeth_chroma"/* "$XET_READY_DIR/chromadb/" 2>/dev/null || echo "  ⚠️ ChromaDB copy may have partial issues"
    echo "  ✓ ChromaDB data"
fi

# 3. Log Files
echo "3. Backing up log files..."
if [ -d "/workspace/elizabeth_logs" ]; then
    mkdir -p "$XET_READY_DIR/logs"
    cp -r "/workspace/elizabeth_logs"/* "$XET_READY_DIR/logs/" 2>/dev/null
    echo "  ✓ Log files"
fi

# 4. Configuration Files
echo "4. Backing up configuration..."
mkdir -p "$XET_READY_DIR/config"

# Environment file
if [ -f "/workspace/elizabeth-repo/.env" ]; then
    cp "/workspace/elizabeth-repo/.env" "$XET_READY_DIR/config/"
    echo "  ✓ .env configuration"
fi

# 5. Repository Code
echo "5. Backing up repository code..."
mkdir -p "$XET_READY_DIR/code"
cp -r "/workspace/elizabeth-repo"/* "$XET_READY_DIR/code/" 2>/dev/null

# Remove any large or unnecessary files
find "$XET_READY_DIR/code" -name "*.pyc" -delete
find "$XET_READY_DIR/code" -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true

echo "  ✓ Repository code"

# 6. Create manifest file
echo "6. Creating data manifest..."
cat > "$XET_READY_DIR/manifest.json" << EOF
{
    "version": "1.0",
    "timestamp": "$(date -Iseconds)",
    "elizabeth_version": "v0.0.2",
    "data_sources": [
        {
            "type": "sqlite_databases",
            "files": ["elizabeth_memory.db", "nova_memory.db"],
            "description": "Primary conversation and memory storage"
        },
        {
            "type": "chromadb",
            "description": "Semantic search and vector memory"
        },
        {
            "type": "logs", 
            "description": "Conversation logs and activity history"
        },
        {
            "type": "configuration",
            "files": [".env"],
            "description": "Environment configuration and API keys"
        },
        {
            "type": "source_code",
            "description": "Complete Elizabeth repository with versions v0.0.1 and v0.0.2"
        }
    ],
    "total_size_mb": $(du -sm "$XET_READY_DIR" 2>/dev/null | cut -f1 || echo 0),
    "backup_type": "full_xet_ready",
    "instructions": "This directory contains all Elizabeth data ready for Xet push. Upload entire directory to Xet repository."
}
EOF

echo "  ✓ Manifest file"

# 7. Create push instructions
echo "7. Creating push instructions..."
cat > "$XET_READY_DIR/XET_PUSH_INSTRUCTIONS.md" << 'EOF'
# Xet Push Instructions for Elizabeth Data

## Prerequisites
1. Install Xet CLI: `curl -s https://xetbeta.com/install.sh | bash`
2. Ensure git-xet command is available: `git xet --help`

## Push to Xet Repository

### Option 1: Initialize New Repository
```bash
cd /workspace/xet_data
git xet init
git remote add origin https://xetbeta.com/adaptnova/elizabeth-data
git xet add .
git xet commit -m "Elizabeth full data backup $(date +%Y-%m-%d)"
git xet push origin main
```

### Option 2: Manual Upload
1. Upload this entire directory to: https://xetbeta.com/adaptnova/elizabeth-data
2. Use Xet web interface or CLI

### Option 3: GitHub + Xet Sync
1. Push to GitHub first: https://github.com/adaptnova/elizabeth
2. Use Xet-GitHub integration for data versioning

## Data Contents
- `/databases/` - SQLite databases with all conversations and memories
- `/chromadb/` - Semantic search vector database  
- `/logs/` - Conversation logs and activity history
- `/config/` - Environment configuration
- `/code/` - Complete source code repository

## Verification
After push, verify data integrity:
```bash
git xet verify
git xet log --oneline
```
EOF

echo "  ✓ Push instructions"

# 8. Final summary
echo ""
echo "=== XET DATA PREPARATION COMPLETE ==="
echo "Location: $XET_READY_DIR"
echo "Total size: $(du -sh $XET_READY_DIR | cut -f1)"
echo ""
echo "Next steps:"
echo "1. Install Xet CLI: curl -s https://xetbeta.com/install.sh | bash"
echo "2. Push to Xet: cd $XET_READY_DIR && follow XET_PUSH_INSTRUCTIONS.md"
echo "3. Or manually upload to: https://xetbeta.com/adaptnova/elizabeth-data"
echo ""
echo "All Elizabeth data is now prepared and ready for Xet push!"

# Create symlink to latest
ln -sfn "$XET_READY_DIR" "$BACKUP_DIR/latest"
echo "Latest backup symlink: $BACKUP_DIR/latest"