# Evaluation Maintenance Guide

This document provides a comprehensive guide to maintaining and managing the Raga Catalyst infrastructure, covering key operational tasks and configurations.

<details>

<summary>IP Address Update</summary>

**Purpose:** Update the VM IP address

**Command:**

```bash
bash $HOME/raga-evaluation-scripts/scripts/update_ip_address.sh
```

</details>

<details>

<summary>Proxy URL Update</summary>

**Purpose:** Update the proxy server URL

**Command:**

```bash
bash $HOME/raga-evaluation-scripts/scripts/update_proxy_url.sh <proxy_server_endpoint>
```

*Note: Replace `<proxy_server_endpoint>` with the actual proxy server endpoint*

</details>

<details>

<summary>Enable Backups for AWS Instance</summary>

\### Purpose Enable periodic backups for the Raga Catalyst AWS instance.

#### Step 1: Create an IAM Policy

1. Go to the **IAM Console** in AWS
2. Navigate to **Policies** > **Create Policy**
3. Choose the **JSON** tab and enter the following policy:

```json
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeVolumes",
                "ec2:DescribeInstances",
                "ec2:CreateSnapshot",
                "ec2:DescribeSnapshots",
                "ec2:CreateTags",
                "ec2:DeleteSnapshot"
            ],
            "Resource": "*"
        }
    ]
}
```

4. Click **Next** and provide a name: `RagaCatalyst-EbsSnapshot-Policy`
5. Review and create the policy

#### Step 2: Create an IAM Role

1. Go to the **IAM Console** and navigate to **Roles**
2. Click **Create Role**
3. Under **Select trusted entity**, choose **AWS service**
4. Choose **EC2** as the use case
5. Click **Next** and attach the previously created policy
6. Give the role a name: `RagaCatalyst-EbsSnapshot-Role`
7. Create the role

#### Step 3: Attach the Role to an EC2 Instance

1. Go to the **EC2 Console**
2. Select the instance you want to modify
3. Click **Actions** > **Security** > **Modify IAM role**
4. Select the role `RagaCatalyst-EbsSnapshot-Role` and save

#### Step 4: Schedule a Cron Job for Snapshots

SSH into the EC2 instance and execute:

```bash
(crontab -l; echo "0 1 * * * bash $HOME/raga-evaluation-scripts/scripts/aws-ebs-backup.sh") | crontab -
```

*Note: This creates an AMI snapshot once a day at 1 AM UTC. Adjust the cron expression as needed.*

</details>

<details>

<summary>Enable Backups for GCP Instance</summary>

#### Purpose

Enable periodic backups for the Raga Catalyst GCP instance.

### Prerequisites

* GCP Console access with Owner or Editor role
* VM instance details (IP address)
* IAM permissions to modify service accounts and VM configurations

### Configuration Steps

#### 1. Project Configuration

1. Navigate to [GCP Console](https://console.cloud.google.com)
2. Verify active project in top navigation
3. Document:
   * Project ID
   * Project Number (from Dashboard > Project Info)

#### 2. VM Instance Setup

1. Access Compute Engine > VM Instances
2. Locate target VM using Internal/External IP
3. Document instance details:
   * Instance name
   * Zone
   * IP addresses

#### 3. Service Account Configuration

**Initial Setup**

1. Stop the VM instance
2. Navigate to instance settings
3. Click "Edit"

**Service Account Attachment**

1. Select "Compute Engine default service account"
   * Format: `PROJECT_NUMBER-compute@developer.gserviceaccount.com`
2. Configure Access Scopes:
   * Set "Access for each API"
   * Enable:
     * Compute Engine: "Read Write"
     * Storage: "Read Write"
     * Cloud Platform: "Full Access"
3. Save and restart VM

**Note**: Public IP may change after restart. Document new IP.

#### 4. IAM Role Setup

1. Navigate to IAM & Admin > IAM
2. Locate compute service account
3. Add "Compute Storage Admin" role
4. Save changes

#### 5. Snapshot Scheduling

1. SSH into Azure VM
2. Execute:

   ```bash
   echo "0 1 * * * $HOME/raga-evaluation-scripts/scripts/GCP-disk-backup.sh" | crontab -
   ```

   This creates daily snapshots at 1 AM UTC.

### Verification

1. VM Configuration:
   * Confirm service account attachment
   * Verify configured scopes
2. IAM Settings:
   * Check storage admin role assignment
   * Verify permissions

### Technical Requirements

#### Service Account

* Format: `PROJECT_NUMBER-compute@developer.gserviceaccount.com`
* Required scopes:
  * compute-rw
  * storage-rw
  * cloud-platform

#### VM State

* Must be stopped for service account modifications
* Must be running for snapshot operations

### Important Notes

* Both service account scopes AND IAM roles are required
* Allow full VM startup before testing
* Verify all permissions before snapshot operations
* Cron schedule can be modified based on requirements

### Support

For additional assistance or issues, please contact your system administrator or GCP support team.

</details>

<details>

<summary>Enable Backups for Azure Instance</summary>

#### Purpose

Enable periodic backups for the Raga Catalyst Azure instance.

### Enable System-Assigned Managed Identity

Follow these steps in the Azure Portal:

1. Open the Azure Portal
2. Navigate to the Virtual Machines service and select your VM
3. In the left-hand menu, find the Identity section under Settings
4. Under the System-assigned tab, toggle the Status to On
5. Click Save
6. Note down the Object ID of the managed identity once enabled

### Grant Permissions to the Managed Identity

The managed identity needs appropriate permissions to execute operations like fetching VM metadata, retrieving disk information, and managing snapshots.

#### Identify Resource Group

1. Navigate to the Overview section of the VM in Azure Portal
2. Note down the Resource Group name

#### Assign Required Roles

1. Navigate to the Resource Group of the VM
2. Click on Access Control (IAM) in the left-hand menu
3. Click + Add > Add role assignment
4. Select the Disk Snapshot Contributor role
5. Under "Assign access to", select Managed identity
6. Search for your VM's managed identity and click Save

### Schedule Snapshot Creation

To set up automatic snapshot creation:

1. SSH into the Azure VM using terminal
2. Execute the following command to schedule snapshots:

   ```bash
   echo "0 1 * * * $HOME/raga-evaluation-scripts/scripts/Azure-disk-backup.sh" | crontab -
   ```

   This configuration creates an AMI snapshot daily at 1 AM UTC. You can modify the cron expression based on your requirements.

</details>
