Restore .rdb snapshots into a cross account — Via AWS Cli | Ranjeet Borate
Lets assume we have 2 accounts such as AccountOne and AccountTwo, and we need to export the .rdb from ElastiCache of AccountOne and restore it in ElastiCache of AccounTwo. So this is a cross account scenario and we will achieve this by AWS CLI. Note that we cannot restore the rdb snapshot in the existing cluster instead of that we should create a new cluster for the restoration.
Below is the path which we will follow in order to accomplish the above given scenario.
Steps:
- Export .rdb snapshot from ElastiCache from AccountOne and upload it to S3 bucket of the same Account. (Copy Snapshot to S3)
- Create the Replication Cluster in the ElastiCache of AccountB with the required Node Type(Node Type is explained later in this blog), and add the snapshot path located in the S3 bucket of Cross Account AccountOne. ()
Node Type
It has to do with the size of the cluster being created. There are various Node Types and are used as per the requirement of the snapshot being restored. Below are few of the Node Types:
- cache.t3.micro: Offers 0.5 GB of memory for Nodes being created
- cache.t3.small: Offers 1.3 GB of memory for Nodes being created
- cache.t3.medium: Offers 3.2 GB of memory for Nodes being created
- cache.r5.large: Offers 15.25 GB of memory for Nodes being created
- cache.r5.xlarge: Offers 31 GB of memory for Nodes being created
- cache.r5.2xlarge: Offers 61 GB of memory for Nodes being created
- cache.r5.4xlarge: Offers 122 GB of memory for Nodes being created
AWS CLI Commands
We perform below operations sequentially:
- Creating a copy of snapshot and place it onto the destination S3 bucket
- Create replication group with particular required node type and snapshot arn which is to be restored while creating the replication group/cluster
Command syntax to create a copy of the snapshot and put it into S3
copy-snapshot
--source-snapshot-name <value>
--target-snapshot-name <value>
[--target-bucket <value>]
[--kms-key-id <value>]
[--tags <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
Command syntax to create replication group at first place
create-replication-group
--replication-group-id <value>
--replication-group-description <value>
[--global-replication-group-id <value>]
[--primary-cluster-id <value>]
[--automatic-failover-enabled | --no-automatic-failover-enabled]
[--multi-az-enabled | --no-multi-az-enabled]
[--num-cache-clusters <value>]
[--preferred-cache-cluster-azs <value>]
[--num-node-groups <value>]
[--replicas-per-node-group <value>]
[--node-group-configuration <value>]
[--cache-node-type <value>]
[--engine <value>]
[--engine-version <value>]
[--cache-parameter-group-name <value>]
[--cache-subnet-group-name <value>]
[--cache-security-group-names <value>]
[--security-group-ids <value>]
[--tags <value>]
[--snapshot-arns <value>]
[--snapshot-name <value>]
[--preferred-maintenance-window <value>]
[--port <value>]
[--notification-topic-arn <value>]
[--auto-minor-version-upgrade | --no-auto-minor-version-upgrade]
[--snapshot-retention-limit <value>]
[--snapshot-window <value>]
[--auth-token <value>]
[--transit-encryption-enabled | --no-transit-encryption-enabled]
[--at-rest-encryption-enabled | --no-at-rest-encryption-enabled]
[--kms-key-id <value>]
[--user-group-ids <value>]
[--log-delivery-configurations <value>]
[--data-tiering-enabled | --no-data-tiering-enabled]
[--network-type <value>]
[--ip-discovery <value>]
[--transit-encryption-mode <value>]
[--cluster-mode <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]
Command syntax to delete the replication group
delete-replication-group
--replication-group-id <value>
[--retain-primary-cluster | --no-retain-primary-cluster]
[--final-snapshot-identifier <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
[--debug]
[--endpoint-url <value>]
[--no-verify-ssl]
[--no-paginate]
[--output <value>]
[--query <value>]
[--profile <value>]
[--region <value>]
[--version <value>]
[--color <value>]
[--no-sign-request]
[--ca-bundle <value>]
[--cli-read-timeout <value>]
[--cli-connect-timeout <value>]
[--cli-binary-format <value>]
[--no-cli-pager]
[--cli-auto-prompt]
[--no-cli-auto-prompt]