# Configuration settings for an Aerospike Backup on Kubernetes

## Overview

Aerospike Backup configuration settings are in the Aerospike Backup Custom Resource (CR). Aerospike Kubernetes Operator (AKO) monitors this file to schedule backups or trigger an immediate on-demand backup.

The [AerospikeBackup Custom Resource Definition (CRD)](https://github.com/aerospike/aerospike-kubernetes-operator/blob/v4.1.2/config/crd/bases/asdb.aerospike.com_aerospikebackups.yaml) specifies the CR structure that AKO uses to configure and create the backup.

## CR examples

CR examples are available in [the main Aerospike Kubernetes Operator repository](https://github.com/aerospike/aerospike-kubernetes-operator/tree/v4.1.2/config/samples).

### Example 1: CR with scheduled backups

This example schedules periodic full and incremental backups for an Aerospike cluster.

Example 1

```yaml
apiVersion: asdb.aerospike.com/v1beta1

kind: AerospikeBackup

metadata:

    name: aerospikebackup

    namespace: aerospike

spec:

  backupService:

    name: aerospikebackupservice

    namespace: aerospike

  config:

    aerospike-cluster:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

      aerospike-aerospikebackup-test-cluster:

        credentials:

          password: admin123

          user: admin

        seed-nodes:

          - host-name: aerocluster.aerospike.svc.cluster.local

            port: 3000

    backup-routines:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

      aerospike-aerospikebackup-test-routine:

        backup-policy: test-policy

        interval-cron: "@daily"

        incr-interval-cron: "@hourly"

        namespaces: ["test"]

        source-cluster: aerospike-aerospikebackup-test-cluster

        storage: local
```

### Example 2: CR with scheduled backups with a password file path

This example schedules periodic Full and Incremental backups for an Aerospike cluster with a password file path.

Example 2

```yaml
apiVersion: asdb.aerospike.com/v1beta1

kind: AerospikeBackup

metadata:

    name: aerospikebackup

    namespace: aerospike

spec:

  backupService:

    name: aerospikebackupservice

    namespace: aerospike

  config:

    aerospike-cluster:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

      aerospike-aerospikebackup-test-cluster:

        credentials:

          # Make sure the password file is mounted in the backup service pod via secret at the path specified here.

          password-path: /etc/aerospike/secret/password

          user: admin

        seed-nodes:

          - host-name: aerocluster.aerospike.svc.cluster.local

            port: 3000

    backup-routines:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

      aerospike-aerospikebackup-test-routine:

        backup-policy: test-policy

        interval-cron: "@daily"

        incr-interval-cron: "@hourly"

        namespaces: ["test"]

        source-cluster: aerospike-aerospikebackup-test-cluster

        storage: local
```

## Configuration

The initial part of the CR file selects the CRD and the namespace to use for the Aerospike Backup.

```yaml
apiVersion: asdb.aerospike.com/v1beta1

kind: AerospikeBackup

metadata:

  name: aerospikebackup

  namespace: aerospike
```

The rest of this page explains the parameters in the subsequent parts of the CR file.

## Spec

The spec section defines the backup’s configurations.

| Field | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| [backupService](#backup-service) | Yes | Structure |  | Aerospike backup service reference. |
| [config](#config) | Yes | Structure |  | Aerospike backup configuration in freeform YAML format. |
| [onDemandBackups](#on-demand-backups) | No | Structure | nil | List of on-demand backups to be triggered. |

## Backup service

[`spec`](#spec) -> `backupService`

Configure the Aerospike backup service to be used for taking backups.

| Field | Required | Type | Description |
| --- | --- | --- | --- |
| name | Yes | String | Name of the backup service. |
| namespace | Yes | String | Namespace of the backup service. |

## Config

[`spec`](#spec) -> `config`

The YAML form of Aerospike Backup configuration. The following fields can be defined in the Aerospike Backup configuration:

-   `aerospike-cluster`: only one Aerospike cluster can be configured.
-   `backup-routines`: multiple backup routines can be configured.

Example:

```yaml
config:

  aerospike-cluster:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

    aerospike-aerospikebackup-test-cluster:

      credentials:

        password: admin123

        user: admin

      seed-nodes:

        - host-name: aerocluster.aerospike.svc.cluster.local

          port: 3000

  backup-routines:

      # Name format: The name must begin with the prefix <backup-namespace>-<backup-name>

    aerospike-aerospikebackup-test-routine:

      backup-policy: test-policy

      interval-cron: "@daily"

      incr-interval-cron: "@hourly"

      namespaces: ["test"]

      source-cluster: aerospike-aerospikebackup-test-cluster

      storage: local
```

### Resource naming rule:

`aerospike-cluster` and `backup-routines` names must start with a prefix `<backup-namespace>-<backup-name>`. The prefix is the namespace and name of the backup CR.

See the [Aerospike Backup Configuration reference](https://aerospike.com/docs/database/tools/backup-and-restore/backup-service/config-examples) for more details.

### On-demand Backups

[`spec`](#spec) -> `onDemandBackups`

Configure the on-demand backups for an Aerospike cluster.

| Field | Required | Type | Description |
| --- | --- | --- | --- |
| id | Yes | String | Unique identifier for the on-demand request operation in the CR. |
| routineName | Yes | String | Routine name to use to trigger on-demand backup. |
| delay | No | String | Delay interval before starting the on-demand backup. |