Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Backup AWS Elasticache Redis Data?

I'm testing a new Redis cluster (AWS Large primary/slave nodes) in AWS Elasticache Redis.

How can I backup or export my data from the Redis cluster?

Other hosted redis services automatically create a Redis RDB dump file and store it on S3. I would like to do something similar with ElastiCache.

like image 975
Winfield Avatar asked Sep 18 '13 15:09

Winfield


2 Answers

EDIT: New AWS Feature as of 4/24/2014

Amazon has added internal backup support as of 4/24. This allows you to snapshot redis data daily and restore it to an ElastiCache cluster. It does not allow exporting/downloading at the present. The solution below is still required if you want to keep your own archives/backups of redis data.

Most people should be able to use the built in backup system now available.

Original Answer

It looks like the only way to do this is to do the following.

  • Spin up new EC2 instance
  • Install Redis
  • Configure local replica attached to ElastiCache redis primary
  • Wait for data to sync locally
  • Issue a redis SAVE command to generate a local dump
  • Archive local dump.rdb on S3

I'd love a simpler solution or something built into ElastiCache.

EDIT: Elaboration

I ended up actually building this using the Ruby gem/utility "redis-backup" (https://github.com/josegonzalez/ruby-redis-backup) with a crontab running the following shell command:

sudo -u redis /usr/bin/env S3_SAVE=true redis-backup -s /var/lib/redis/dump.rdb -B YOUR_S3_BUCKET_FOR_BACKUPS -A S3_ACCESS_KEY_ID -S S3_ACCESS_SECRET_KEY
like image 174
Winfield Avatar answered Nov 08 '22 12:11

Winfield


It doesn't look like this is possible anymore. According to the AWS docs,

"Beginning with Redis 2.8.22, ElastiCache no longer supports external read replicas."

like image 20
Dave K Avatar answered Nov 08 '22 12:11

Dave K