Home > Blockchain >  Write AWS Elasticache (Redis) Query Output To S3 Path
Write AWS Elasticache (Redis) Query Output To S3 Path

Time:10-21

I want to get all the keys from AWS Redis DB exported to an S3 path as text file so that I can analyze the keys that are getting created in the db.

How can I export all the keys from redis-cli to a S3 path?

Can this command be used to write to a S3 path?

redis-cli -h 10.1.xx.xx -n 1 keys * >s3://bucket/path/filename.txt

CodePudding user response:

After installing AWS CLI, you can copy your local file to your s3 in the command line.

# copy a single file to a specified bucket and key
aws s3 cp test.txt s3://mybucket/test2.txt

# upload a local file stream from standard input to a specified bucket and key
aws s3 cp - s3://mybucket/stream.txt

So, you can upload your stdout to your s3 like this

redis-cli -h 10.1.xx.xx -n 1 keys * | aws s3 cp - s3://bucket/path/filename.txt
  • Related