> [!CAUTION]
> You are currently viewing version 1.7 of the Apigee hybrid documentation. **This version is end of life.** You should upgrade to a newer version. For more information, see [Supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions).

<button class="button button-with-icon cloud-select-dropdown__button button-primary" aria-haspopup="true">Version 1.7 (unsupported)</button>

- Supported versions:
- [v1.17 (latest)](https://docs.cloud.google.com/apigee/docs/hybrid/v1.17/restore-cassandra-single-region.md.txt)
- [v1.16](https://docs.cloud.google.com/apigee/docs/hybrid/v1.16/restore-cassandra-single-region.md.txt)
- [v1.15](https://docs.cloud.google.com/apigee/docs/hybrid/v1.15/restore-cassandra-single-region.md.txt)
- [v1.14](https://docs.cloud.google.com/apigee/docs/hybrid/v1.14/restore-cassandra-single-region.md.txt)
- [List of supported versions](https://docs.cloud.google.com/apigee/docs/hybrid/supported-platforms.md.txt#supported-versions)
- Unsupported versions:
- [v1.13](https://docs.cloud.google.com/apigee/docs/hybrid/v1.13/restore-cassandra-single-region.md.txt)
- [v1.12](https://docs.cloud.google.com/apigee/docs/hybrid/v1.12/restore-cassandra-single-region.md.txt)
- [v1.11](https://docs.cloud.google.com/apigee/docs/hybrid/v1.11/restore-cassandra-single-region.md.txt)
- [v1.10](https://docs.cloud.google.com/apigee/docs/hybrid/v1.10/restore-cassandra-single-region.md.txt)
- [v1.9](https://docs.cloud.google.com/apigee/docs/hybrid/v1.9/restore-cassandra-single-region.md.txt)
- [v1.8](https://docs.cloud.google.com/apigee/docs/hybrid/v1.8/restore-cassandra-single-region.md.txt)
- [v1.7](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/restore-cassandra-single-region.md.txt)
- [v1.6](https://docs.cloud.google.com/apigee/docs/hybrid/v1.6/restore-cassandra-single-region.md.txt)
- [v1.5](https://docs.cloud.google.com/apigee/docs/hybrid/v1.5/restore-cassandra-single-region.html)
- [v1.4](https://docs.cloud.google.com/apigee/docs/hybrid/v1.4/restore-cassandra-single-region.html)
- [v1.3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.3/restore-cassandra-single-region.html)
- [v1.2](https://docs.cloud.google.com/apigee/docs/hybrid/v1.2/restore-cassandra-single-region.html)
- [v1.1](https://docs.cloud.google.com/apigee/docs/hybrid/v1.1/restore-cassandra-single-region.html)

This page describes how to restore Cassandra in a single region.

In a single region deployment, Apigee hybrid is deployed in a single data center or a region. If you
have multiple Apigee organizations in your deployment, the restore process restores data for all the organizations.
In a multi-organization setup, you cannot restore a specific organization.

> [!NOTE]
> **Note** : Before you begin restoring a single region, consider whether the following prerequisite steps are applicable:
>
> - If you want to preserve an existing setup for troubleshooting and root cause analysis (RCA), you should delete all the `org` and `env` components from the Kubernetes cluster *except* the Apigee controller, and then retain the cluster. The cluster will contain the existing Apigee datastore (Cassandra) which you can use for troubleshooting. Create a new Kubernetes cluster and then restore Cassandra in the new cluster.
> - If your hybrid installation was set up with multiple organizations, get the overrides files for each organization before proceeding with restore in a single region. You can add the restore configuration as described in [Step 3](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/restore-cassandra-single-region.md.txt#step3) to any **one** of the overrides files. Do not add the restore configuration to any other overrides file.

## Restoring a region from a backup

In your configuration, the Cassandra backup can reside either on Cloud Storage or
on a remote server. In either case, perform the following steps to restore:

1. Verify the hybrid version.

   ```
   apigeectl version
   ```
   Ensure the version is the same version that created the backup files in storage.

   > [!TIP]
   > **Tip:** Run every `apigeectl` command with the `--dry-run=true` flag first to check for any apigeectl errors.

2. Confirm that the Kubernetes cluster you are restoring to does not have a prior Apigee hybrid installation. If you are restoring to the existing cluster, use the following commands to delete the existing Apigee hybrid installation:

       apigeectl delete -f overrides.yaml
       kubectl -n apigee get apigeedatastore,apigeeredis,apigeetelemetry,org,env,arc # The output should be empty.
       apigeectl delete --all -f overrides.yaml

3. Open your `overrides.yaml` file and set the `restore` properties to the desired values:

   ### Cloud Storage

   ### Parameters

   ```
   namespace: YOUR_RESTORE_NAMESPACE # Use the namespace as in your original cluster.
   cassandra:
     hostNetwork: false
     ...
     restore:
       enabled: true
       serviceAccountPath: "SA_JSON_FILE_PATH"
       dbStorageBucket: "CLOUD_STORAGE_BUCKET_PATH"
       cloudProvider: "GCP"  # required verbatim "GCP" (all caps)
       snapshotTimestamp: "TIMESTAMP"
     ...
     backup:
       enabled: true
       serviceAccountPath: "SA_JSON_FILE_PATH"
       dbStorageBucket: "CLOUD_STORAGE_BUCKET_PATH"
       cloudProvider: "GCP"  # required verbatim "GCP" (all caps)
       schedule: "SCHEDULE"
   ```

   ### Example

   ```
   namespace: apigee
   cassandra:
     hostNetwork: false
     ...
     restore:
       enabled: true
       serviceAccountPath: "/Users/myhome/.ssh/my_cassandra_backup.json"
       dbStorageBucket: "gs://myname-cassandra-backup"
       cloudProvider: "GCP"
       snapshotTimestamp: "20201001183903"
     ...
     backup:
       enabled: true
       serviceAccountPath: "/Users/myhome/.ssh/my_cassandra_backup.json"
       dbStorageBucket: "gs://myname-cassandra-backup"
       cloudProvider: "GCP"
       schedule: "0 2 * * *"
     ...
   ```


   Where:

   | Property | Description |
   |---|---|
   | `namespace` | <var translate="no">YOUR_RESTORE_NAMESPACE</var> Namespace for restore. Use the namespace as in your original cluster. |
   | `cassandra:hostNetwork` | `hostNetwork` is required and should always be set to `false`. |
   | `restore:enabled` | Restore is disabled by default. You must set this property to `true`. |
   | `restore:serviceAccountPath` | <var translate="no">SA_JSON_FILE_PATH</var> The path on your filesystem to the service account you created for the backup. |
   | `restore:dbStorageBucket` | <var translate="no">CLOUD_STORAGE_BUCKET_PATH</var> The Cloud Storage bucket path where your backup data is stored in the following format: `gs://BUCKET_NAME`. The `gs://` is required. |
   | `restore:cloudProvider` | **`GCP`** The `cloudProvider: "GCP"` property is required. |
   | `restore:snapshotTimestamp` | <var translate="no">TIMESTAMP</var> The timestamp of the backup snapshot to restore. To check what timestamps can be used, go to the `dbStorageBucket` and look at the files that are present in the bucket. Each file name contains a timestamp value. For example, `backup_20210203213003_apigee-cassandra-default-0.tgz` Where <var translate="no">20210203213003</var> is the `snapshotTimestamp` value you would use if you wanted to restore the backups created at that point in time. |
   | `backup:enabled` | Backup is disabled by default. You must set this property to `true`. |
   | `backup:serviceAccountPath` | <var translate="no">SA_JSON_FILE_PATH</var> The path on your filesystem to the service account JSON file that was downloaded when you ran `./tools/create-service-account` |
   | `backup:dbStorageBucket` | <var translate="no">CLOUD_STORAGE_BUCKET_PATH</var> The Cloud Storage bucket path in this format: `gs://BUCKET_NAME`. The `gs://` is required. |
   | `backup:cloudProvider` | **`GCP`** The `cloudProvider: "GCP"` property is required. |
   | `backup:schedule` | <var translate="no">SCHEDULE</var> The time when the backup starts, specified in [standard crontab syntax](https://en.wikipedia.org/wiki/Cron). Default: `0 2 * * *` > [!NOTE] > **Note:** Avoid scheduling a backup that starts a short time after you apply the backup configuration to your cluster. When you apply the backup configuration, Kubernetes recreates the Cassandra nodes. If the backup starts before the nodes restart (possibly several minutes) the backup will fail. |

   ### Non-Cloud Storage

   ### Parameters

   ```
   namespace: YOUR_RESTORE_NAMESPACE # Use the namespace as in your original cluster.
   cassandra:
     hostNetwork: false
     ...
     restore:
       enabled: true
       keyFile: "PATH_TO_PRIVATE_KEY_FILE"
       server: "BACKUP_SERVER_IP"
       storageDirectory: "/home/apigee/BACKUP_DIRECTORY"
       cloudProvider: "HYBRID"  # required verbatim "HYBRID" (all caps)
       snapshotTimestamp: "TIMESTAMP"
     ...
     backup:
       enabled: true
       keyFile: "PATH_TO_PRIVATE_KEY_FILE"
       server: "BACKUP_SERVER_IP"
       storageDirectory: "/home/apigee/BACKUP_DIRECTORY"
       cloudProvider: "HYBRID" # required verbatim "HYBRID" (all caps)
       schedule: "SCHEDULE"
   ```

   ### Example

   ```
   namespace: apigee
   cassandra:
     hostNetwork: false
     ...
     restore:
       enabled: true
       keyFile: "/Users/exampleuser/apigee-hybrid/hybrid-files/service-accounts/private.key"
       server: "34.56.78.90"
       storageDirectory: "/home/apigee/cassbackup"
       cloudProvider: "HYBRID"
       snapshotTimestamp: "20201001183903"
     ...
     backup:
       enabled: true
       keyFile: "/Users/exampleuser/apigee-hybrid/hybrid-files/service-accounts/private.key"
       server: "34.56.78.90"
       storageDirectory: "/home/apigee/cassbackup"
       cloudProvider: "HYBRID"
       schedule: "0 2 * * *"
     ...
   ```


   Where:

   | Property | Description |
   |---|---|
   | `namespace` | <var translate="no">YOUR_RESTORE_NAMESPACE</var> Namespace for restore. Use the namespace as in your original cluster. |
   | `cassandra:hostNetwork` | `hostNetwork` is required and should always be set to `false`. |
   | `restore:enabled` | Restore is disabled by default. You must set this property to `true`. |
   | `restore:keyFile` | <var translate="no">PATH_TO_PRIVATE_KEY_FILE</var> The path on your local file system to the SSH private key file (named `ssh_key` in [the step where you created the SSH key pair](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/restore-cassandra-single-region.md.txt#create-key)). |
   | `restore:server` | <var translate="no">BACKUP_SERVER_IP</var> The IP address of your backup server. |
   | `restore:storageDirectory` | <var translate="no">BACKUP_DIRECTORY</var> The name of the backup directory on your backup server. This must be a directory within `home/apigee` (the backup directory is named `cassandra_backup` in [the step where you created the backup directory](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/restore-cassandra-single-region.md.txt#make_dir)). |
   | `restore:cloudProvider` | **`HYBRID`** The `cloudProvider: "HYBRID"` property is required. |
   | `restore:snapshotTimestamp` | <var translate="no">TIMESTAMP</var> The timestamp of the backup snapshot to restore. To check what timestamps can be used, go to the `dbStorageBucket` and look at the files that are present in the bucket. Each file name contains a timestamp value. For example, `backup_20210203213003_apigee-cassandra-default-0.tgz` Where <var translate="no">20210203213003</var> is the `snapshotTimestamp` value you would use if you wanted to restore the backups created at that point in time. |
   | `backup:enabled` | Backup is disabled by default. You must set this property to `true`. |
   | `backup:keyFile` | <var translate="no">PATH_TO_PRIVATE_KEY_FILE</var> The path on your local file system to the SSH private key file (named `ssh_key` in [the step where you created the SSH key pair](https://docs.cloud.google.com/apigee/docs/hybrid/v1.7/restore-cassandra-single-region.md.txt#create-key)). |
   | `backup:server` | <var translate="no">BACKUP_SERVER_IP</var> The IP address of your backup server. |
   | `backup:storageDirectory` | <var translate="no">BACKUP_DIRECTORY</var> The name of the backup directory on your backup server. This must be a directory within `home/apigee` (the backup directory is named `cassandra_backup` in the step where you created the backup directory). |
   | `backup:cloudProvider` | **`HYBRID`** The `cloudProvider: "HYBRID"` property is required. |
   | `backup:schedule` | <var translate="no">SCHEDULE</var> The time when the backup starts, specified in [standard crontab syntax](https://en.wikipedia.org/wiki/Cron). Default: `0 2 * * *` > [!NOTE] > **Note:** Avoid scheduling a backup that starts a short time after you apply the backup configuration to your cluster. When you apply the backup configuration, Kubernetes recreates the Cassandra nodes. If the backup starts before the nodes restart (possibly several minutes) the backup will fail. |

   > [!NOTE]
   > **Note:** Apigee restores Cassandra from a Cloud Storage backup or a remote server backup based on the `backup` configuration in the `overrides.yaml` file.

4. Create a new hybrid runtime deployment. This will create a new Cassandra cluster and begin restoring the backup data into the cluster:

   ```
   ${APIGEECTL_HOME}/apigeectl init  -f overrides/overrides.yaml
   ```

   ```
   ${APIGEECTL_HOME}/apigeectl check-ready -f overrides/overrides.yaml
   ```

   ```
   ${APIGEECTL_HOME}/apigeectl apply -f overrides/overrides.yaml --restore
   ```

   ```
   ${APIGEECTL_HOME}/apigeectl check-ready -f overrides/overrides.yaml
   ```
5. Verify the restoration job progress and confirm that `apigeeds` and all the other pods are up:
   - To check `apigeeds`:

     ```
     kubectl get apigeeds -n apigee
     ```
   - To check all other pods:

     ```
     kubectl get pods -n apigee
     ```

Upon successful completion of the restore and confirmation that the runtime components are healthy,
we recommend configuring a backup on the cluster:

1. Remove the `restore` configuration from the `overrides-restore.yaml` file.
2. Add the `backup` configuration to the `overrides-restore.yaml` file.
3. Apply the `backup` configuration with the following command:

   ```
   ./apigeectl apply -f ../overrides-restore.yaml
   ```