# Snapshot Mount

## Definition

Trilio allows you to view or download a file from the snapshot. Any changes to the files or directories when snapshot is mounted are temporary and are discarded when the snapshot is unmounted. Mounting is a faster way to restore a single or multiple files. To mount a snapshot follow these steps.

## Supported File Recovery Manager Image

| **Cloud Image Name** | **Version**    | **Supported**        |
| -------------------- | -------------- | -------------------- |
| Ubuntu               | Bionic(18.04)  | :heavy\_check\_mark: |
| Ubuntu               | Focal(20.04)   | :heavy\_check\_mark: |
| Centos               | Centos8        | :heavy\_check\_mark: |
| Centos               | Centos8 stream | :heavy\_check\_mark: |
| RHEL                 | RHEL7          | :heavy\_check\_mark: |
| RHEL                 | RHEL8          | :heavy\_check\_mark: |
| RHEL                 | RHEL9          | :heavy\_check\_mark: |

## Create a File Recovery Manager Instance

{% hint style="success" %}
It is recommended to do these steps once to the chosen cloud-Image and then upload the modified cloud image to Glance.
{% endhint %}

* Create an OpenStack image using a Linux based cloud-image like Ubuntu, CentOS or RHEL with the following metadata parameters.

```
openstack image create \
--file <File Manager Image Path> \
--container-format bare \
--disk-format qcow2 \
--public \
--property hw_qemu_guest_agent=yes \
--property tvault_recovery_manager=yes \
--property hw_disk_bus=virtio \
tvault-file-manager
```

* Spin up an instance from that image\
  It is recommended to have at least 8GB RAM for the mount operation.\
  Bigger Snapshots can require more RAM.

⚠️ **Note:** After creating the FRM instance, it must be tagged with `tvault_recovery_manager`. This tag is required for Horizon to identify the FRM using the Nova API.

Use the following command to add the tag:

```
openstack server set --os-compute-api-version 2.26 --tag "tvault_recovery_manager" <FRM_UUID>
```

### Steps to apply on CentOS and RHEL cloud-images

* install and activate qemu-guest-agent
* Edit `/etc/sysconfig/qemu-ga` and remove the following from BLACKLIST\_RPC section

```
guest-file-read
guest-file-write
guest-file-open
guest-file-close
```

* Disable SELINUX in /etc/sysconfig/selinux

```
SELINUX=disabled
```

* Install python3 and lvm2

```
yum install python3 lvm2
```

* Reboot the Instance

### Steps to apply on Ubuntu cloud-images

* install and activate qemu-guest-agent

```
apt-get update
apt-get install qemu-guest-agent
systemctl enable qemu-guest-agent
```

* Verify the loaded path of qemu-guest-agent

#### Loaded path init.d (Ubuntu 18.04)

Follow this path when systemctl returns the following loaded path

```
Loaded: loaded (/etc/init.d/qemu-guest-agent; generated)
```

Edit `/etc/init.d/qemu-guest-agent` and add Freeze-Hook file path in daemon args

```
DAEMON_ARGS="-F/etc/qemu/fsfreeze-hook"
```

#### Loaded path systemd (Ubuntu 20.04)

Follow this path when systemctl returns the following loaded path

```
Loaded: loaded (/usr/lib/systemd/system/qemu-guest-agent.service; disabled; vendor preset: enabled)
```

Edit `qemu-guest-agent systemd` file

```
systemctl edit qemu-guest-agent
```

Add the following lines

```
[Service]
ExecStart=
ExecStart=/usr/sbin/qemu-ga -F/etc/qemu/fsfreeze-hook
```

#### Finalize the FRM on Ubuntu

* Restart qemu-guest-agent service

```
systemctl restart qemu-guest-agent
```

* Install Python3

```
apt-get install python3
```

* Reboot the VM

## Mounting a Snapshot

Mounting a Snapshot to a File Recovery Manager provides read access to all data that is located on the in the mounted Snapshot.

{% hint style="danger" %}
It is possible to run the mounting process against any OpenStack instance. During this process will the instance be rebooted.

Always mount Snapshots to File Recovery Manager instances only.
{% endhint %}

{% hint style="info" %}
To be able to successfully mount Windows (NTFS) Snapshots the ntfs filesystem support is required on the File Recovery Manager instance.
{% endhint %}

{% hint style="warning" %}
Unmount any mounted Snapshot once there is no further need to keep it mounted. Mounted Snapshots will not be purged by the Retention policy.
{% endhint %}

### Using Horizon

There are 2 possibilities to mount a Snapshot in Horizon.

#### Through the Snapshot list

To mount a Snapshot through the Snapshot list follow these steps:

1. Login to Horizon
2. Navigate to Backups
3. Navigate to Workloads
4. Identify the workload that contains the Snapshot to mount
5. Click the workload name to enter the Workload overview
6. Navigate to the Snapshots tab
7. Identify the searched Snapshot in the Snapshot list
8. Click the small arrow in the line of the Snapshot next to "One Click Restore" to open the submenu
9. Click "Mount Snapshot"
10. Choose the File Recovery Manager instance to mount to
11. Confirm by clicking "Mount"

{% hint style="warning" %}
Should all instances of the project be listed and there is a File Recovery Manager instance existing verify together with the administrator that the File Recovery Manager image has the following property set:

`tvault_recovery_manager=yes`
{% endhint %}

#### Through the File Search results

To mount a Snapshot through the File Search results follow these steps:

1. Login to Horizon
2. Navigate to Backups
3. Navigate to Workloads
4. Identify the workload that contains the Snapshot to mount
5. Click the workload name to enter the Workload overview
6. Navigate to the File Search tab
7. [Do a File Search](https://docs.trilio.io/openstack/user-guide/file-search)
8. Identify the Snapshot to be mounted
9. Click "Mount Snapshot" for the chosen Snapshot
10. Choose the File Recovery Manager instance to mount to
11. Confirm by clicking "Mount"

{% hint style="warning" %}
Should all instances of the project be listed and there is a File Recovery Manager instance existing verify together with the administrator that the File Recovery Manager image has the following property set:

`tvault_recovery_manager=yes`
{% endhint %}

### Using CLI

```
workloadmgr snapshot-mount <snapshot_id> <mount_vm_id>
```

* `<snapshot_id>` :arrow\_right: ID of the Snapshot to be mounted
* `<mount_vm_id>` :arrow\_right: ID of the File Recovery Manager instance to mount the Snapshot to.

## Accessing the File Recovery Manager

The File Recovery Manager is a normal Linux based OpenStack instance.

It can be accessed via SSH or SSH based tools like FileZila or WinSCP.

{% hint style="info" %}
SSH login is often disabled by default in cloud-images. Enable SSH login if necessary.
{% endhint %}

The mounted Snapshot can be found at the following path:

`/mnt/tvault-mounts/mounts/`

Each VM in the Snapshot has its own directory using the VM\_ID as the identifier.

## Identifying mounted Snapshots

Sometimes a Snapshot is mounted for a longer time and it needs to be identified, which Snapshots are mounted.

### Using Horizon

There are 2 possibilities to identify mounted Snapshots inside Horizon.

#### From the File Recovery Manager instance Metadata

1. Login to Horizon
2. Navigate to Compute
3. Navigate to Instances
4. Identify the File Recovery Manager Instance
5. Click on the Name of the File Recovery Manager Instance to bring up its details
6. On the Overview tab look for Metadata
7. Identify the value for `mounted_snapshot_url`

The `mounted_snapshot_url` contains the Snapshot ID of the Snapshot that has been mounted last.

{% hint style="info" %}
This value only gets updated, when a new Snapshot is mounted.
{% endhint %}

#### From the Snapshot list

1. Login to Horizon
2. Navigate to Backups
3. Navigate to Workloads
4. Identify the workload that contains the Snapshot to mount
5. Click the workload name to enter the Workload overview
6. Navigate to the Snapshots tab
7. Search for the Snapshot that has the option "Unmount Snapshot"

### Using CLI

```
workloadmgr snapshot-mounted-list [--workloadid <workloadid>]
```

* `--workloadid <workloadid>` :arrow\_right: Restrict the list to snapshots in the provided workload

## Unmounting a Snapshot

Once a mounted Snapshot is no longer needed it is possible and recommended to unmount the snapshot.

{% hint style="info" %}
Unmounting a Snapshot frees the File Recovery Manager instance to mount the next Snapshot and allows Trilio retention policy to purge the former mounted Snapshot.
{% endhint %}

{% hint style="warning" %}
Deleting the File Recovery Manager instance will not update the Trilio appliance. The Snapshot will be considered mounted until an unmount command has been received.
{% endhint %}

### Using Horizon

1. Login to Horizon
2. Navigate to Backups
3. Navigate to Workloads
4. Identify the workload that contains the Snapshot to mount
5. Click the workload name to enter the Workload overview
6. Navigate to the Snapshots tab
7. Search for the Snapshot that has the option "Unmount Snapshot"
8. Click "Unmount Snapshot"

### Using the CLI

```
workloadmgr snapshot-dismount <snapshot_id>
```

* `<snapshot_id>` :arrow\_right: ID of the snapshot to unmount.
