claude-os/scripts/restore_claude_os.sh
Claude f6a1d6b417
🗂️ ORGANIZE: Reorganize root directory structure
Moved 25 files from root to organized subdirectories while keeping
essential scripts (install.sh, setup.sh, start*.sh, stop*.sh) in root.

## Changes:

### New Directory Structure:
- Created `/scripts/` for utility scripts
- Created `/docs/guides/` for user guides
- Created `/docs/development/` for dev documentation
- Created `/docs/archive/` for historical/legacy docs

### Moved Files:

**To `/scripts/` (7 files):**
- backup_claude_os.sh
- restore_claude_os.sh
- run_tests.sh
- setup_native.sh
- start_mcp_server.sh
- start_redis_workers.sh
- entrypoint.sh

**To `/docs/guides/` (7 files):**
- AUTH_SETUP.md
- BACKUP_RESTORE_GUIDE.md
- HOOK_SETUP_QUICK_START.md
- SHARING_GUIDE.md
- START_SCRIPTS_GUIDE.md
- PORTS_GUIDE.md
- WHAT_IS_CLAUDE_OS.md

**To `/docs/development/` (4 files):**
- COMPREHENSIVE_REVIEW.md
- SECURITY_FIXES.md
- CLAUDE_OS_DEVELOPER_GUIDE.md
- PROJECT_SETUP_AND_COMMANDS.md

**To `/docs/archive/` (10 files):**
- HYBRID_INDEXING_COMPLETE.md
- INITIALIZE_PROJECT_HOOKS_FIX.md
- INSTALL_ENHANCEMENTS.md
- INSTALL_FIXES.md
- PISTN_TEST_RESULTS.md
- SESSION_SUMMARY.md
- TEST_COVERAGE.md
- TEST_RESULTS.md
- TESTING_STATUS.md
- README_TESTING.md

### Updated References:

**Fixed broken documentation links in:**
- docs/QUICK_REFERENCE.md
- docs/PRODUCTION_DEPLOYMENT.md
- docs/SCRIPTS_GUIDE.md
- docs/development/SECURITY_FIXES.md
- docs/guides/BACKUP_RESTORE_GUIDE.md
- docs/development/CLAUDE_OS_DEVELOPER_GUIDE.md
- tests/TESTING_GUIDE.md
- tests/TEST_COVERAGE.md

**Script references updated to:**
- `./scripts/backup_claude_os.sh`
- `./scripts/restore_claude_os.sh`
- `./scripts/run_tests.sh`
- `./scripts/setup_native.sh`
- `./scripts/start_mcp_server.sh`
- `./scripts/start_redis_workers.sh`

### Remaining in Root (9 essential files):
- install.sh
- setup.sh
- start.sh
- start_all_services.sh
- stop_all_services.sh
- restart_services.sh
- README.md
- CLAUDE.md
- requirements.txt (+ GEMINI_DIAGRAM_PROMPT.md)

## Benefits:
✅ Cleaner root directory (9 files vs 34 files)
✅ Organized documentation by purpose
✅ Scripts grouped in dedicated directory
✅ Essential startup commands still in root
✅ All references updated and verified
✅ No broken links

Version: 2.0.2
2025-11-04 21:34:26 +00:00

138 lines
4.1 KiB
Bash
Executable file

#!/bin/bash
# Claude OS Restore Script
# This script restores a previously backed up Claude OS installation
set -e # Exit on error
# Colors for output
GREEN='\033[0;32m'
BLUE='\033[0;34m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${BLUE}============================================${NC}"
echo -e "${BLUE} Claude OS Restore Script${NC}"
echo -e "${BLUE}============================================${NC}"
echo ""
# Get the directory where this script is located
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
# Check if backup timestamp was provided
if [ -z "$1" ]; then
echo -e "${RED}Error: No backup timestamp provided${NC}"
echo ""
echo "Usage: $0 <timestamp>"
echo ""
echo "Available backups:"
if [ -d "backups" ]; then
ls -1 backups/ | grep backup_ | sed 's/backup_/ /'
else
echo " No backups found"
fi
exit 1
fi
TIMESTAMP="$1"
BACKUP_DIR="$SCRIPT_DIR/backups/backup_$TIMESTAMP"
# Check if backup exists
if [ ! -d "$BACKUP_DIR" ]; then
echo -e "${RED}Error: Backup not found at $BACKUP_DIR${NC}"
echo ""
echo "Available backups:"
if [ -d "backups" ]; then
ls -1 backups/ | grep backup_ | sed 's/backup_/ /'
else
echo " No backups found"
fi
exit 1
fi
echo -e "${YELLOW}Restoring from backup: $TIMESTAMP${NC}"
echo -e "${YELLOW}Backup location: $BACKUP_DIR${NC}"
echo ""
# Show manifest if it exists
if [ -f "$BACKUP_DIR/MANIFEST.txt" ]; then
echo -e "${BLUE}Backup Manifest:${NC}"
cat "$BACKUP_DIR/MANIFEST.txt"
echo ""
fi
# Ask for confirmation
echo -e "${RED}WARNING: This will overwrite your current Claude OS data!${NC}"
echo -e "${YELLOW}Press Enter to continue, or Ctrl+C to cancel...${NC}"
read -r
# Function to restore a file or directory
restore_item() {
local backup_path="$1"
local dest_path="$2"
local item_name="$3"
if [ -e "$backup_path" ]; then
echo -e "${GREEN}✓${NC} Restoring: $item_name"
# Create parent directory if needed
mkdir -p "$(dirname "$dest_path")"
if [ -d "$backup_path" ]; then
rm -rf "$dest_path" 2>/dev/null || true
cp -r "$backup_path" "$dest_path"
else
cp "$backup_path" "$dest_path"
fi
else
echo -e "${YELLOW}⚠${NC} Skipping (not in backup): $item_name"
fi
}
echo ""
echo -e "${BLUE}1. Restoring database...${NC}"
restore_item "$BACKUP_DIR/claude-os.db" "data/claude-os.db" "SQLite database"
echo ""
echo -e "${BLUE}2. Restoring configuration files...${NC}"
restore_item "$BACKUP_DIR/.env" ".env" "Environment variables"
restore_item "$BACKUP_DIR/claude-os-config.json" "claude-os-config.json" "Project config"
restore_item "$BACKUP_DIR/claude-os-state.json" "claude-os-state.json" "Session state"
restore_item "$BACKUP_DIR/claude-os-triggers.json" "claude-os-triggers.json" "Trigger phrases"
echo ""
echo -e "${BLUE}3. Restoring uploaded files...${NC}"
restore_item "$BACKUP_DIR/uploads" "data/uploads" "Uploaded documents"
echo ""
echo -e "${BLUE}4. Restoring logs...${NC}"
if [ -d "$BACKUP_DIR/logs" ]; then
mkdir -p "logs"
cp "$BACKUP_DIR/logs"/*.log logs/ 2>/dev/null || true
echo -e "${GREEN}✓${NC} Restored log files"
else
echo -e "${YELLOW}⚠${NC} No logs in backup"
fi
echo ""
echo -e "${BLUE}5. Checking symlinks...${NC}"
if [ -f "$BACKUP_DIR/symlink_info.txt" ]; then
echo -e "${YELLOW}Symlink information (for reference):${NC}"
cat "$BACKUP_DIR/symlink_info.txt"
echo ""
echo -e "${BLUE}Note: Symlinks are managed by install.sh${NC}"
echo -e "If you need to recreate them, run: ${YELLOW}./install.sh${NC}"
fi
echo ""
echo -e "${BLUE}============================================${NC}"
echo -e "${GREEN}✓ Restore completed successfully!${NC}"
echo -e "${BLUE}============================================${NC}"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo -e " 1. Start Claude OS: ${GREEN}./start.sh${NC}"
echo -e " 2. Verify services: ${GREEN}curl http://localhost:8051/health${NC}"
echo -e " 3. Check UI: ${GREEN}http://localhost:5173${NC}"
echo ""