Restore .rdb snapshots into a cross account — Via AWS Cli | Ranjeet Borate

Ranjeet Borate
4 min readMay 19, 2023

--

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:

  1. Export .rdb snapshot from ElastiCache from AccountOne and upload it to S3 bucket of the same Account. (Copy Snapshot to S3)
  2. 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:

  1. cache.t3.micro: Offers 0.5 GB of memory for Nodes being created
  2. cache.t3.small: Offers 1.3 GB of memory for Nodes being created
  3. cache.t3.medium: Offers 3.2 GB of memory for Nodes being created
  4. cache.r5.large: Offers 15.25 GB of memory for Nodes being created
  5. cache.r5.xlarge: Offers 31 GB of memory for Nodes being created
  6. cache.r5.2xlarge: Offers 61 GB of memory for Nodes being created
  7. cache.r5.4xlarge: Offers 122 GB of memory for Nodes being created

AWS CLI Commands

We perform below operations sequentially:

  1. Creating a copy of snapshot and place it onto the destination S3 bucket
  2. 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]

--

--

Ranjeet Borate
Ranjeet Borate

Written by Ranjeet Borate

Interested in Tech • General Knowledge Awareness • Astronomy • Airforce and Aircrafts • History • Trekking

No responses yet