Skip to content

Instantly share code, notes, and snippets.

@Muazzeem
Created May 31, 2023 04:12
Show Gist options
  • Save Muazzeem/cef8ef7e69ecb94a08ec2c035f0934fa to your computer and use it in GitHub Desktop.
Save Muazzeem/cef8ef7e69ecb94a08ec2c035f0934fa to your computer and use it in GitHub Desktop.

Redis Backup and Restore

This guide provides step-by-step instructions on how to backup Elasticache, copy the backup to Amazon S3, create GCP Redis, select network, allocate IP range, create a storage bucket, and upload the backup file. Finally, it explains how to import the backup file after Redis starts.

Prerequisites

Before proceeding with the backup and restore process, make sure you have the following:

  • Access to the Elasticache instance
  • Access to an Amazon S3 bucket
  • Access to GCP and the ability to create a Redis instance
  • Basic knowledge of the AWS CLI, GCP CLI, and Redis commands

Backup Elasticache

  1. Connect to the Elasticache instance using the appropriate method (e.g., SSH, console).
  2. Execute the backup command specific to your Elasticache setup to create a backup file.
  3. Make a note of the location and name of the backup file.

Copy to S3

  1. Use the AWS CLI to copy the backup file to an S3 bucket:

Create GCP Redis

  1. Open the GCP Console and navigate to the Redis page.
  2. Click on "Create Instance" to create a new Redis instance.
  3. Configure the Redis instance according to your requirements, including memory, region, and other settings.
  4. Make a note of the connection details (e.g., hostname, port) provided by GCP.

Select Network and Allocate IP Range

  1. In the GCP Console, navigate to the VPC network section.
  2. Ensure that the Redis instance is associated with the appropriate network.
  3. Allocate an IP range within the network to be used by the Redis instance.

Create Storage Bucket and Upload Backup File

  1. In GCP Console, go to the Storage Browser.
  2. Click on "Create Bucket" to create a new storage bucket.
  3. Specify a unique name and configuration for the bucket.
  4. Upload the backup file to the newly created bucket.

Import Backup File after Redis Start

  1. Connect to the GCP Redis instance using the appropriate method (e.g., GCP Console, CLI).
  2. Execute the Redis command to import the backup file:

Replace <redis_hostname> and <redis_port> with the appropriate values obtained from GCP. Replace <backup_file> with the path and name of the backup file stored in the GCP storage bucket.

Conclusion

By following the steps outlined in this guide, you should be able to successfully backup Elasticache, copy it to S3, create GCP Redis, select network, allocate IP range, create a storage bucket, and upload the backup file. Finally, you can import the backup file after Redis starts.

Please note that this guide provides a general overview and may require additional configuration or customization based on your specific environment and requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment