> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ahmadraza.in/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenSearchMigrationTool

# OpenSearch Migration Tool

A unified web application for managing OpenSearch snapshots and migrations with a clean, professional UI.

## Features

* 🔧 **Register Repository**: Register S3 repositories with OpenSearch clusters
* 📸 **Take Snapshot**: Create snapshots of your indices for backup or migration
* 🔄 **Restore Snapshot**: Restore snapshots to your target OpenSearch cluster
* 🎨 **Clean UI**: Professional Material-UI based interface
* 🔐 **Secure**: Uses your local AWS CLI credentials and environment variables for secrets

## Setup

This guide will help you to setup OpenSearch Migration Tool

```bash theme={null}
# clone the repository
git clone https://github.com/ahmadrazalab/AWS-OpenSearch-MigrationTool.git
```

### Prerequisites

* Python 3.8+
* Node.js 18+
* AWS CLI configured with appropriate credentials
* Virtual environment (venv) - already created in this project

### Configuration

1. **Update .env file** with your specific values:

```bash theme={null}
# OpenSearch Configuration
REGION=ap-south-1
SERVICE=es

# OpenSearch Endpoints
OLD_OPENSEARCH_HOST=https://your-old-opensearch-endpoint.region.es.amazonaws.com
NEW_OPENSEARCH_HOST=https://your-new-opensearch-endpoint.region.es.amazonaws.com

# S3 Repository Settings
ROLE_ARN=arn:aws:iam::account:role/YourOpenSearchRole
BUCKET_NAME=your-opensearch-backup-bucket
REPO_NAME=migration-repo

# Default Snapshot Settings
DEFAULT_INDICES=fraudulents*,refunds-*
DEFAULT_SNAPSHOT_PREFIX=full-backup-snapshot
```

### Running the Application

#### Full Setup and Run

```bash theme={null}
./run.sh
```

#### Development Mode (faster, assumes dependencies installed)

```bash theme={null}
./dev-run.sh
```

#### Manual Run

```bash theme={null}
# Activate virtual environment
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Build frontend
cd frontend && npm install && npm run build && cd ..

# Start server
python main.py
```

## Usage

1. **Access the application** at `http://localhost:8000`

2. **Register Repository Tab**:
   * Select endpoint type (Old/New OpenSearch cluster)
   * Click "Register Repository" to set up S3 repository

3. **Take Snapshot Tab**:
   * Select source endpoint (Old/New cluster)
   * Optionally specify snapshot name (auto-generated if empty)
   * Optionally specify indices (uses default from .env if empty)
   * Click "Take Snapshot"

4. **Restore Snapshot Tab**:
   * Browse available snapshots or enter snapshot name manually
   * Optionally specify indices to restore
   * Click "Restore Snapshot" (always restores to new cluster)

## API Endpoints

* `POST /api/register-repo` - Register S3 repository
* `POST /api/take-snapshot` - Create a snapshot
* `POST /api/restore-snapshot` - Restore a snapshot
* `GET /api/snapshots/{endpoint_type}` - List snapshots
* `GET /api/health` - Health check

## Technology Stack

* **Backend**: FastAPI with Python
* **Frontend**: React + Vite + Material-UI
* **Authentication**: Uses local AWS CLI credentials
* **Deployment**: Single server serves both API and static frontend

## File Structure

```
├── main.py              # FastAPI backend server
├── requirements.txt     # Python dependencies
├── .env                # Configuration (update this!)
├── run.sh              # Full setup and run script
├── dev-run.sh          # Quick development run
├── frontend/           # React frontend
│   ├── src/
│   │   ├── App.jsx
│   │   └── components/
│   └── dist/           # Built frontend (auto-generated)
├── venv/               # Python virtual environment
└── *.py                # Original migration scripts
```

## Notes

* The application uses your existing AWS CLI credentials
* All sensitive configuration is stored in `.env`
* The frontend is built and served as static files by FastAPI
* Single server deployment - no need to run frontend and backend separately
