This page explains how to perform common tasks for AOF and RDB persistence.

For more information about persistence, see [Persistence overview](https://docs.cloud.google.com/memorystore/docs/cluster/persistence-overview.md.txt).

## RDB persistence tasks

This section gives instructions for common RDB persistence tasks.

### Create an instance that uses RDB persistence

### Console

1. In the **Data persistence strategy** section, select the **Redis Database (RDB)** option
   when [Creating an instance](https://docs.cloud.google.com/memorystore/docs/cluster/create-instances.md.txt).

2. Select a snapshot interval from the **Snapshot interval** menu.

3. Select a start time from the **Start time (local time)** menu.

### gcloud

To create an instance that uses RDB persistence, run the `create` command:

```
gcloud redis clusters create instance-id \
  --region=region-id \
  --network=network \
  --replica-count=replica-count \
  --node-type=node-type \
  --shard-count=shard-count \
  --persistence-mode=rdb \
  --rdb-snapshot-period=snapshot-interval \
  --rdb-snapshot-start-time=time
```

Replace the following:

- <var translate="no">instance-id</var> is the ID of the Memorystore for Redis Cluster instance you're creating. Your instance ID must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number.

- <var translate="no">region-id</var> is the region where you want the instance placed.

- <var translate="no">network</var> is the network used to create your instance. It must use the format: `projects/NETWORK_PROJECT_ID/global/networks/NETWORK_ID`. The network ID used here must match the network ID used by the service connection policy. Otherwise, the `create` operation fails.

- <var translate="no">replica-count</var> is the number of replicas (per shard). Accepted values are `0`-`5`.

- <var translate="no">node-type</var> is the [node type](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt#choose_a_node_type) for the cluster.

  > [!CAUTION]
  > **Caution** : We recommend that you use the `redis-shared-core-nano` node type only for development or testing purposes because this node type has no SLA. If you run Memorystore for Redis Cluster in a production environment, then we recommend using another node type.

- <var translate="no">shard-count</var> determines the number of shards in your instance. Shard count determines the total memory capacity for storing cluster data. For more information about cluster specification, see [Cluster and node specification](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt).

- <var translate="no">snapshot-interval</var> is your chosen interval. Accepted values are `1h`, `6h`, `12h`, and `24h`. The default value is `24h`.

- <var translate="no">time</var> is the start time of your RDB snapshot in the ISO 1801 format. For example: `2024-04-08T03:00:00Z`. If you don't choose a start time when creating an instance that uses RDB persistence, the first snapshot is taken immediately.

### Enable RDB persistence for an existing instance

> [!NOTE]
> **Note:** If you enable or disable persistence for an existing instance, then the instance might need to perform [maintenance](https://docs.cloud.google.com/memorystore/docs/cluster/about-maintenance.md.txt).

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select the **Redis Database (RDB)** option.

5. Select a snapshot interval from the **Snapshot interval** menu.

6. Select a start time from the **Start time (local time)** menu.

7. Click the **Update Cluster** button.

### gcloud

To enable RDB persistence for an existing instance, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --persistence-mode=rdb \
  --rdb-snapshot-period=snapshot-interval \
  --rdb-snapshot-start-time=time
```

Replace the following:

- <var translate="no">instance-id</var> is the ID of the Memorystore for Redis Cluster instance you're creating. Your instance ID must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number.

- <var translate="no">region-id</var> is the region where you want the instance placed.

- <var translate="no">snapshot-interval</var> is your chosen interval. Accepted values are `1h`, `6h`, `12h`, and `24h`. The default value is `24h`.

- <var translate="no">time</var> is the start time of your RDB snapshot in the ISO 1801 format. For example: `2024-04-08T03:00:00Z`. If you don't choose a start time when enabling RDB persistence on an existing instance, the first snapshot is taken immediately.

### Adjust RDB snapshot interval

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select your chosen snapshot interval from the **Snapshot interval** menu.

5. Click the **Update Cluster** button.

### gcloud

To adjust the RDB snapshot interval, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --rdb-snapshot-period=snapshot-interval
```

Replace the following:

- <var translate="no">snapshot-interval</var> is your chosen interval. Accepted values are `1h`, `6h`, `12h`, and `24h`. The default value is `24h`.

- <var translate="no">time</var> is your chosen start time in the ISO 1801 format. For example: `2024-04-08T03:00:00Z`.

### Adjust the RDB snapshot start time

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select your chosen start time from the **Start time (local time)** menu.

5. Click the **Update Cluster** button.

### gcloud

To adjust the RDB snapshot start time, run the `update` command. Changing the start time also changes the snapshot alignment time. For example, if you change the start time from 6:00 AM to 6:30 AM, with a snapshot frequency of `1h`, future snapshots align at 7:30 AM, 8:30 AM, 9:30 AM and every hour after that.

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --rdb-snapshot-start-time=time
```

Replace the following:

- <var translate="no">time</var> is your chosen start time in the ISO 1801 format. For example: `2024-04-08T03:00:00Z`.

### Pause RDB persistence

### gcloud

To pause RDB persistence, you must set the snapshot schedule to a future time. When you want to unpause snapshots, you can re-adjust the time to when you want the next snapshot to occur.

To pause RDB snapshots, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --rdb-snapshot-start-time=time
```

Replace the following:

- <var translate="no">time</var> is your chosen start time in the ISO 1801 format. For example: `2024-04-08T03:00:00Z`.

> [!NOTE]
> **Note:** Pausing snapshots will result in stale backups and can result in the instance being recovered with stale data. If you need to pause snapshots for a long period of time, consider disabling RDB snapshot instead.

### Disable RDB persistence

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select the **No persistence** option.

5. Click the **Update Cluster** button.

### gcloud

To disable RDB persistence, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --persistence-mode=disabled
```

> [!NOTE]
> **Note:** Disabling persistence disables both backup and restore. Nodes will not load from older snapshots created before persistence was disabled.

### Monitor RDB persistence

You can use [Cloud Monitoring](https://docs.cloud.google.com/memorystore/docs/cluster/monitor-instances.md.txt) to view metrics for RDB persistence.

For a list of available metrics for RDB persistence, see [persistence metrics](https://docs.cloud.google.com/memorystore/docs/cluster/supported-monitoring-metrics.md.txt#persistence_metrics).

## AOF persistence tasks

This section gives instructions for common AOF persistence tasks.

### Create an instance that uses AOF persistence

### Console

1. In the **Data persistence strategy** section, select the **Append Only File (AOF)** option
   when [Creating an instance](https://docs.cloud.google.com/memorystore/docs/cluster/create-instances.md.txt).

2. Select a sync setting from the **AOF Fsync mode** menu.

### gcloud

To create an instance that uses AOF persistence, run the `create` command:

```
gcloud redis clusters create instance-id \
  --region=region-id \
  --network=network \
  --replica-count=replica-count \
  --node-type=node-type \
  --shard-count=shard-count \
  --persistence-mode=aof \
  --aof-append-fsync=fsync-frequency
```

Replace the following:

- <var translate="no">instance-id</var> is the ID of the Memorystore for Redis Cluster instance you're creating. Your instance ID must be 1 to 63 characters and use only lowercase letters, numbers, or hyphens. It must start with a lowercase letter and end with a lowercase letter or number.

- <var translate="no">region-id</var> is the region where you want the instance placed.

- <var translate="no">network</var> is the network used to create your instance. It must use the format: `projects/NETWORK_PROJECT_ID/global/networks/NETWORK_ID`. The network ID used here must match the network ID used by the service connection policy. Otherwise, the `create` operation fails.

- <var translate="no">replica-count</var> is the number of replicas (per shard). Accepted values are `0`-`5`.

- <var translate="no">node-type</var> is the [node type](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt#choose_a_node_type) for the cluster.

  > [!CAUTION]
  > **Caution** : We recommend that you use the `redis-shared-core-nano` node type only for development or testing purposes because this node type has no SLA. If you run Memorystore for Redis Cluster in a production environment, then we recommend using another node type.

- <var translate="no">shard-count</var> determines the number of shards in your instance. Shard count determines the total memory capacity for storing cluster data. For more information about cluster specification, see [Cluster and node specification](https://docs.cloud.google.com/memorystore/docs/cluster/cluster-node-specification.md.txt).

- <var translate="no">fsync-frequency</var> is your [sync setting](https://docs.cloud.google.com/memorystore/docs/cluster/about-aof-persistence.md.txt#sync_setting). Accepted values are `always`, `everysec`, and `no`. `everysec` is the default for this parameter.

### Enable AOF persistence for an existing instance

> [!NOTE]
> **Note:** If you enable or disable persistence for an existing instance, then the instance might need to perform [maintenance](https://docs.cloud.google.com/memorystore/docs/cluster/about-maintenance.md.txt).

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select the **Append Only File (AOF)** option.

5. Select a sync setting from the **AOF Fsync mode** menu.

6. Click the **Update Cluster** button.

### gcloud

To enable AOF persistence on an instance, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --persistence-mode=aof \
  --aof-append-fsync=fsync-frequency
```

Replace the following:

- <var translate="no">fsync-frequency</var> is your [sync setting](https://docs.cloud.google.com/memorystore/docs/cluster/about-aof-persistence.md.txt#sync_setting). Accepted values are `always`, `everysec`, and `no`. `everysec` is the default for this parameter.

### Adjust the AOF sync setting for your instance

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select your chosen sync setting from the **AOF fsync mode** menu.

5. Click the **Update Cluster** button.

### gcloud

To adjust the sync setting for an instance that uses AOF persistence, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --aof-append-fsync=fsync-frequency
```

Replace the following:

- <var translate="no">fsync-frequency</var> is your [sync setting](https://docs.cloud.google.com/memorystore/docs/cluster/about-aof-persistence.md.txt#sync_setting). Accepted values are `always`, `everysec`, and `no`. `everysec` is the default for this parameter.

### Disable AOF persistence

### Console

1. Go to the **Memorystore for Redis Cluster** page in the Google Cloud console.

   [Memorystore for Redis Cluster](https://console.cloud.google.com/memorystore/redis/clusters)
2. Click your instance ID.

3. In the **Configurations** section, click the pencil icon next to **Persistence**.

4. Select the **No persistence** option.

5. Click the **Update Cluster** button.

### gcloud

To disable AOF persistence, run the `update` command:

```
gcloud redis clusters update instance-id \
  --region=region-id \
  --persistence-mode=disabled
```

> [!NOTE]
> **Note:** Disabling persistence disables both backup and restore. Nodes will not load from older snapshots created before disable.

### Monitor AOF persistence

You can use [Cloud Monitoring](https://docs.cloud.google.com/memorystore/docs/cluster/monitor-instances.md.txt) to view metrics for AOF persistence.

For a list of available metrics for AOF persistence, see [persistence metrics](https://docs.cloud.google.com/memorystore/docs/cluster/supported-monitoring-metrics.md.txt#persistence_metrics).