{Redis}Backup 復元ElastiCache for Redis

Redis (クラスターモードが有効) は、
クラスターレベル (API または CLI ではレプリケーショングループレベル) でのバックアップの作成のみをサポートしています。
Redis (クラスターモードが有効) は、シャードレベル (API または CLI ではノードグループレベル) でのバックアップの作成をサポートしていません。

(1)クラスターモードが無効(レプリカあり)
-- 1. テスト用クラスタ作成 
aws elasticache create-replication-group \
--replication-group-id redis01 \
--replication-group-description "redis01" \
--num-cache-clusters 2 \
--cache-node-type cache.t3.micro \
--cache-parameter-group default.redis6.x \
--engine redis \
--engine-version 6.x \
--multi-az-enabled

aws elasticache describe-cache-clusters --cache-cluster-id redis01-001 --show-cache-node-info
aws elasticache describe-cache-clusters --cache-cluster-id redis01-002 --show-cache-node-info

-- 2. 手動バックアップの作成

aws elasticache create-snapshot \
--cache-cluster-id redis01-001 \
--snapshot-name snap01

aws elasticache create-snapshot \
--cache-cluster-id redis01-002 \
--snapshot-name snap02

 

-- 3. バックアップの説明

aws elasticache describe-snapshots


-- 4. バックアップからの復元
aws elasticache create-replication-group \
--replication-group-id redis02 \
--replication-group-description "redis02" \
--num-cache-clusters 2 \
--cache-node-type cache.t3.micro \
--cache-parameter-group default.redis6.x \
--engine redis \
--engine-version 6.x \
--multi-az-enabled \
--snapshot-name snap02

 

-- 5. バックアップの削除
aws elasticache delete-snapshot --snapshot-name snap01
aws elasticache delete-snapshot --snapshot-name snap02

-- 6. クリーンアップ

aws elasticache delete-replication-group \
--replication-group-id redis01 \
--no-retain-primary-cluster

aws elasticache delete-replication-group \
--replication-group-id redis02 \
--no-retain-primary-cluster


(2)クラスターモードが有効のクラスタ
-- 1. テスト用クラスタ作成

aws elasticache create-replication-group \
--replication-group-id redis11 \
--replication-group-description "redis11" \
--num-node-groups 2 \
--replicas-per-node-group 1 \
--cache-node-type cache.t3.micro \
--cache-parameter-group default.redis6.x.cluster.on \
--engine redis \
--engine-version 6.x \
--multi-az-enabled

aws elasticache describe-cache-clusters --cache-cluster-id redis11-0001-001 --show-cache-node-info
aws elasticache describe-cache-clusters --cache-cluster-id redis11-0001-002 --show-cache-node-info
aws elasticache describe-cache-clusters --cache-cluster-id redis11-0002-001 --show-cache-node-info
aws elasticache describe-cache-clusters --cache-cluster-id redis11-0002-002 --show-cache-node-info

 

-- 2. 手動バックアップの作成

aws elasticache create-snapshot \
--replication-group-id redis11 \
--snapshot-name snap11

 

-- 3. バックアップの説明

aws elasticache describe-snapshots


-- 4. バックアップからの復元
aws elasticache create-replication-group \
--replication-group-id redis12 \
--replication-group-description "redis12" \
--num-node-groups 2 \
--replicas-per-node-group 1 \
--cache-node-type cache.t3.micro \
--cache-parameter-group default.redis6.x.cluster.on \
--engine redis \
--engine-version 6.x \
--multi-az-enabled \
--snapshot-name snap11

 

-- 5. バックアップの削除
aws elasticache delete-snapshot --snapshot-name snap11


-- 6. クリーンアップ

aws elasticache delete-replication-group \
--replication-group-id redis11 \
--no-retain-primary-cluster

aws elasticache delete-replication-group \
--replication-group-id redis12 \
--no-retain-primary-cluster