# Management Console

To get started with Trilio via the management console in your environment, the following steps must be performed:

## Prerequisites <a href="#install-test-csi-driver" id="install-test-csi-driver"></a>

1. Authenticate access to the Management Console (UI). Refer to[Broken link](https://docs.trilio.io/kubernetes/getting-started/using-trilio/broken-reference "mention").
2. Configure access to the Management Console (UI). Refer to[accessing-the-ui](https://docs.trilio.io/kubernetes/advanced-configuration/management-console/accessing-the-ui "mention").

## Steps Overview

1. Install a compatible CSI Driver
2. Create a Backup Target - A location where backups will be stored.
3. Create a retention policy (Optional) - To specify how long to keep the backups for.
4. Run Example:
   * Label Example
   * Helm Example
   * Operator Example
   * Virtual Machine Example
   * Namespace Example

## Step 1: Install a CSI Driver

{% hint style="info" %}
Skip this step if your environment already has a CSI driver installed with snapshot capability.
{% endhint %}

Trilio for Kubernetes requires a compatible Container Storage Interface (CSI) driver that provides the **Snapshot** feature.

You should check the [Kubernetes CSI Developer Documentation](https://kubernetes-csi.github.io/docs/drivers.html) to select a driver appropriate for your backend storage solution. See the selected CSI driver's documentation for details on the installation of the driver in your cluster.

## Step 2: Create a Target <a href="#create-a-target" id="create-a-target"></a>

Create a secret containing the credentials for data stores to store backups. An example is provided below:

```
apiVersion: v1
kind: Secret
metadata:
  name: sample-secret
type: Opaque
stringData:
  accessKey: AKIAS5B35DGFSTY7T55D
  secretKey: xWBupfGvkgkhaH8ansJU1wRhFoGoWFPmhXD6/vVD
```

You can either create the secret using the above YAML definition or use the management console to create it as part of the workflow for creating the backup target.

![Create secret while creating AWS S3 target](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/2zCqzgL7NiTGilM7XOj4/Screenshot%202023-10-17%20at%205.53.54%20PM.png)

Please use one of the [Target examples](https://docs.trilio.io/kubernetes/getting-started/getting-started-1/triliovault-crds#backup-target) provided in the Custom Resource Definition section as a template for creating an NFS, Amazon S3, or any S3-compatible storage target.

Supported values for S3 vendors include:

```
"AWS", "RedhatCeph", "Ceph", "IBMCleversafe", "Cloudian", "Scality", "NetApp", "Cohesity", "SwiftStack", "Wassabi", "MinIO", "DellEMC", "Other"
```

An Amazon S3 target example is provided below:

![Create demo-s3-target on AWS using above created secret](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/LZuRUJSlMees2P5h0P4F/Screenshot%202023-10-17%20at%206.00.41%20PM.png)

![demo-s3-target created](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/IbMv52V1oehzVs72gx78/target%20list.png)

**Note**: With the above configuration, the target would get created in the current user namespace unless specified. Also, additional information on Bucket permissions can be found here: [aws-s3-target-permissions](https://docs.trilio.io/kubernetes/advanced-configuration/aws-s3-target-permissions "mention")

## Step 3: Create a Retention Policy (Optional)

While the example backup custom resources created by following this Getting Started page can be deleted manually via `kubectl` commands, Trilio also provides backup retention capability - to automatically delete the backups based on defined time boundaries.

![Create demo-retention-policy](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/VCCFzYXeQgDk0CMGm0iC/create%20retention%20policy.png)

![Retention policy created successfully](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/G7yZJG8uVbvfshvCf80z/retention%20policy%20creation.png)

A retention policy is referenced in the [backupPlan CR](https://docs.trilio.io/kubernetes/getting-started/getting-started-1/triliovault-crds#backupplan).

Note: With the above configuration, the policy would get created in the default namespace unless specified.

## Step 4: Create a BackupPlan

This section focuses on creating a `BackupPlan` to define and manage application backups. A `BackupPlan` specifies which resources to back up, such as specific applications or namespaces, and can be configured using labels, Helm, Operators, or namespaces.

For more details on using Custom Resource Definitions (CRDs) with `BackupPlans`, refer to the [BackupPlan Custom Resource Definition Section.](https://docs.trilio.io/kubernetes/getting-started/getting-started-1/triliovault-crds#backupplan)

## Step 4.1: Label Example <a href="#label-example" id="label-example"></a>

This section demonstrates creating a `BackupPlan` to back up a sample application using label-based selection.

The following steps will be performed.

#### 1. Deploy a sample application

Deploy a sample application, such as MySQL, and assign unique, identifiable labels. These labels will appear under the "Labels" tab in the "Application" section. Refer to the guide [here](#id-2.-create-a-label-based-backupplan) for detailed instructions.

#### 2. Create a Label-Based BackupPlan

Create a `BackupPlan` CR through the management console, specifying the MySQL application by selecting its labels from the UI in the same namespace where the application is deployed.

![Select application deployed by label app:mysql and create new BackupPlan](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/NJfjqpzKCOP6W4ahuGMi/label%20plan%20creation.gif)

## Step 4.2: Helm Example

This section outlines the steps to create a `BackupPlan` for a sample application deployed via Helm.

The following steps will be performed.

#### 1. Deploy a Sample Application Using Helm

Deploy a sample Helm application, such as `CockroachDB`. Trilio will display installed Helm applications under the "Helm and Operators" tab in the "Application" section.\
Refer to the guide [here](#id-2.-create-a-helm-based-backupplan) for detailed instructions.

#### 2. Create a Helm-Based BackupPlan

Create a `BackupPlan` Custom Resource (CR) through the management console, specifying the Helm release of the `CockroachDB` application in the `BackupPlan` Helm section.

Ensure the name of the release you specify matches the output from the `helm ls` command in the previous step.

![Enter backupplan name and select target repository. Cockroachdb helm release is part of the backupplan](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/CyTuERin2TxU75F2C9av/helm%20sql%20backupcplan%20creation.gif)

## Step 4.3: Operator Example

This section provides steps for creating a `BackupPlan` for a sample ETCD operator application.

Steps to perform:

#### 1. Install the Etcd Operator and deploy an Etcd cluster (refer to the "[Install Etcd Operator](https://docs.trilio.io/kubernetes/getting-started/getting-started-1#install-etcd-operator)" and "[Create an Etcd Cluster](https://docs.trilio.io/kubernetes/getting-started/getting-started-1#create-an-etcd-cluster-using-following-yaml-definition)" sections for detailed instructions)

Install the Etcd Operator and deploy an Etcd cluster. Trilio will display installed operator applications under the "Helm and Operators" tab in the "Application" section. Refer to the guide [here](#id-2.-create-a-operator-based-backupplan) for detailed instructions.

#### 2. Create a Operator-Based BackupPlan.

Create a `BackupPlan` resource to back up the `etcd-operator` and its clusters. Use the management console to select the `etcd-operator`, which is automatically discovered by T4K and listed under the Operator section.

![Create a backupplan for auto-discovered etcd operator. etcd operator resources captured as a part of backupplan](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/dOHzvlAcRPIQ7jmBExdQ/oper%20backup%20plan%20creation.gif)

## Step 4.4: Virtual Machine Example

This section outlines the process of creating a `BackupPlan` for a sample Virtual Machine.

Steps to perform:

#### 1. Deploy a Sample VirtualMachine

Deploy a sample Virtual Machine (VM) using the OpenShift Virtualization Operator. To learn about VM deployment, refer to the Red Hat demo linked [here](https://www.youtube.com/watch?v=WN9EnqbG8NI). Trilio will list installed VMs under the "Virtual Machines" section. For more detailed instructions, see the guide [here](#id-2.-create-a-backupplan-for-virtualmachine).

#### 2. Create a BackupPlan For VirtualMachine

Create a `BackupPlan` Custom Resource (CR) through the management console, specifying the Virtual Machine for backup. Ensure that the name of the Virtual Machine specified matches the VM created in the previous step.

<figure><img src="https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/E1lCRiUlLNrRwpSxCxFY/virtual%20machine%20backup%20plan%20creation.gif" alt=""><figcaption><p>Virtual Machine auto-discovered by the Trilio for Kubernetes. Create New Backup for Virtual Machine. Provide Backupplan name, Target, and other details. Provide Scheduling Policy, and Retention Policy for the BackupPlan. Virtual Machine Parameters are added under the Custom Component Details.</p></figcaption></figure>

## Step 4.5: Namespace Example

This section outlines the process of creating a `BackupPlan` for a k8s namespace.

#### 1. Create a namespace and application

Follow the [Create a namespace and application](https://docs.trilio.io/kubernetes/getting-started/getting-started-1#create-a-namespace-and-application) section to create an application.

* Create a namespace named `wordpress`.
* Use Helm to deploy a `WordPress` application into the `wordpress` namespace.

Trilio lists the namespaces available in the cluster under the `Namespaces` section. For detailed instructions, refer to the guide [here](#id-2.-create-a-backupplan-for-a-namespace).

#### 2. Create a BackupPlan for a Namespace

Create a `BackupPlan` Custom Resource (CR) through the management console, specifying the `wordpress` namespace for backup.

![Auto-discovered namespaces. Create demo-ns-backupplan. demo-ns-backupplan is in Available state](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/9Uj4YfR9aD9FXRpd1LXd/namespace%20backup%20plan%20creation.gif)

## Step 5: Create Backup

Create a Backup CR through the UI to protect the BackupPlan. The backup can be of type Full or Incremental.

**Note:** The first backup into a target location will always be a Full backup.

Steps to perform

1. Select the `backupPlan` either from the "Backup Plans" tab from the UI and select the "Create Backup" option from the dropdown.
2. Or by choosing the application from the "Applications" section, the namespace from the "Namespaces" section, or the VM from the "Virtual Machines" section. And by clicking the "Create Backup" option in the UI.\
   The available `BackupPlans` for the selected application will be displayed.\
   Select the desired `BackupPlan` and proceed with creating the backup.

#### Refer to this example for backing up a Helm application.

<figure><img src="https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/o3Syuqcw7l6NNB6E1kdm/helm%20sql%20backup%20creation.gif" alt=""><figcaption></figcaption></figure>

#### The backup details can be viewed by selecting the "View Details" option from the dropdown in the backup details section.

![demo-cockroachdb-helm-backup is in Available state](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/5IQBg1xELzIFqlxaQmcK/Screenshot%202023-10-18%20at%204.33.50%20PM%20\(1\).png)

## Step 6: Create Snapshot

Create a Snapshot CR through the UI to protect the BackupPlan. The snapshots are always created as Full snapshots.

Steps to perform

1. Select the `backupPlan` either from the "Backup Plans" tab from the UI and select the "Create Snapshot" option from the dropdown.
2. Or by choosing the application from the "Applications" section, the namespace from the "Namespaces" section, or the VM from the "Virtual Machines" section. And by clicking the "Create Snapshot" option in the UI.\
   The available `BackupPlans` for the selected application will be displayed.\
   Select the desired `BackupPlan` and proceed with creating the snapshot.

#### Refer to this example for taking a snapshot of a Virtual Machine.

<figure><img src="https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/c80eSeszTAQnMGbd0xDm/vm%20snapshot%20creation.gif" alt=""><figcaption></figcaption></figure>

#### The snapshot details can be viewed by selecting the "View Details" option from the dropdown in the snapshot details section.

![demo-snapshot is in Available state](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/5IQBg1xELzIFqlxaQmcK/Screenshot%202023-10-18%20at%204.33.50%20PM%20\(1\).png)

## Step 7: Restore the Application Using a Backup or Snapshot

Finally, create the Restore CR using the UI to restore the backup or snapshot, either in the same or a different namespace.

**Restore to the same cluster in a same namespace**

**Note**: If restoring into the same namespace, ensure that the original application components have been removed. Especially the PVC of the application is deleted.

**Restore to the same cluster but a different namespace**

**Note:** If restoring into another namespace in the same cluster, ensure that the resources that cannot be shared, for example, ports - should be available or transformation should be used to avoid conflict. More information about transformation can be found at [Restore Transformation](https://docs.trilio.io/kubernetes/v/2.1.0/overview/features-and-use-cases#restore-tranforms).

Before restoring the app in the same cluster, the existing app must be removed if it has cluster-scoped resources. This is necessary to prevent conflicts with cluster-level resources that could interfere with the restore operation.

#### Restore from Backup

Steps to perform

* Select the backup by choosing "View Backup and Restore Summary" from the dropdown in the application selection.
* Then, choose the "Restore" option to restore the backup.

#### See this example for restoring an operator backup.

![Select the backup created above from the Restore Points. Enter the restore name and select the restore namespace. demo-etcd-operator-restore is in-progress state](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/fsikvNTVEJlSHN8NhnCh/operator%20backup%20restore.gif)

#### Refer to this example for a completed restore status.

![Restore is in Completed state](https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/HVEy8gAmF5nRJAVTiFjq/Screenshot%202023-10-20%20at%2012.57.36%20PM.png)

#### Restore from Snapshot

Steps to perform

* Select the snapshot by choosing "View Backup and Restore Summary" from the dropdown in the application selection.
* Then, choose the "Restore" option to restore the snapshot.

#### See this example for restoring an namespace snapshot.

<figure><img src="https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/2jFFJEORjmZpQtSxBus6/ns%20sanpshot%20restore.gif" alt=""><figcaption></figcaption></figure>

## Step 8: Restore the Application to a Different Cluster

Trilio enables application backups to be restored into a different cluster. This section focuses on the process of restoring a backup to a different cluster.

**Note**: If restoring to another cluster (migration scenario), ensure that Trilio for Kubernetes is also running in the remote namespace/cluster. To restore into a new cluster (where the Backup CR does not exist), the same target should be created and Target Browsing should be enabled to browse the stored backups.

Steps to perform

1. Enable Target Browsing for the target.
2. Use the "Launch Browser" option.
3. Search for the backup using the BackupPlan name.
4. Select the backup.
5. Click on "Restore."
6. Provide a restore name.
7. Specify the restore namespace.

<figure><img src="https://content.gitbook.com/content/9sDjF5HJP1bf8TtLcgkk/blobs/kYaXHo0f9BfepDeyjk0h/restore%20from%20location.gif" alt=""><figcaption><p>restoring an backup into diffrent cluster</p></figcaption></figure>
