# Restoring Indexes with ASMT

Before restarting the Aerospike node, you can run ASMT to restore the indexes. The length of time it takes to restore indexes depends on their size.

::: note
Starting with version 2.1.0, ASMT requires one or more namespace names when performing a restore operation.
:::

## Prerequisites

-   Ensure that the Aerospike daemon process (`asd`) is not running.
-   Ensure that `asmt` has read permission to the backup files.

## Restore procedure

### (Optional) Pre-run check

You can run `asmt` with the `-a` option to check whether the indexes can be restored, without actually executing the operation.

Terminal window

```bash
sudo ./asmt -a -r -n <namespaces>
```

You must use the `sudo` command, so that `asmt` can run with `uid` and `gid` both set to 0.

| Required option | Description |
| --- | --- |
| `-a` | Analyze whether an index can be restored without performing the restore operation. |
| `-r` | Specifies the restore operation. |
| `-n` | One or more namespaces to be restored. Use a comma-separated list for multiple namespaces. |

### Restore the indexes

Terminal window

```bash
sudo ./asmt -r -v -p <path-to-backup-directory> -n <namespaces>
```

| Required option | Description |
| --- | --- |
| `-r` | Specifies the restore operation. |
| `-p` | Specifies the path to the directory containing the index backup files. |
| `-n` | One or more namespaces to be restored. Use a comma-separated list for multiple namespaces. |

See [Options for ASMT](https://aerospike.com/docs/database/tools/asmt/options) for the complete list of options.

After ASMT restores the indexes, the backup directory still contains backup files.

### Troubleshooting

Do not restart the Aerospike daemon (`asd`) before ASMT finishes restoring the indexes. If you do so, both ASMT and `asd` will fail. If this happens, you must follow these steps:

1.  Delete any shared-memory segments that ASMT created before it failed. You can do so by running this command:
    
    Terminal window
    
    ```bash
    # remove primary index shared memory segments
    
    ipcs | grep ^0xae | awk '{print $1}' | xargs -i sudo ipcrm -M {}
    
    # remove secondary index shared memory segments
    
    ipcs | grep ^0xa2 | awk '{print $1}' | xargs -i sudo ipcrm -M {}
    ```
    
2.  Run `asmt` again to restore the indexes.

## What to do next

With the indexes restored to shared memory, the node can perform a [warm start](https://aerospike.com/docs/database/manage/database/fast-start).