Customize destination of Redis' RDB file
I want to customize the destination of Redis' RDB file to be something other than a file on a mounted file system. For example:
- Send the file to a remote host via scp
- Upload the file to Hadoop HDFS (I'm running Redis on a Hadoop cluster, in which we use HDFS for backup all the time)
- gzip the file and then move it to some archive location
The reason for this is I want to archive the RDB files (my data gets flushed out every day). I'm not sure what I'm going to do with these archived RDB files yet, but I think I'll be able to derive some value from them later.
Is there a way to trigger an external process from Redis when a new dump is made so that I can ship 开发者_JAVA技巧the RDB file to its destination? The most sophisticated thing I can come up with right now is a cron job that checks to see if the file needs to be shipped ever minute or so, but I'd rather have it triggered instead of constantly polling.
I'm pretty new to Redis, so feel free to correct me if you think I'm approaching this problem improperly and suggest a new solution.
Maybe I'm missing something, if you're doing this to preserve data that is going to be wiped out, why not just schedule it to scp it and gzip it right before the days data is flushed? What is the reason for wanting it not to live on a normal file system? To my knowledge there is no way to trigger an external process from within redis when it writes the RDB file. It's going to potentially happen quite frequently depending on your save
settings in the config file. Take a look at this doc to get more information http://redis.io/topics/persistence.
May be I am missing too, but:
You can change where the file is made in redis.conf
You can set up crontab that move/copy the file.
For highest security, do two crontabs - one that move the file (mv data.rdb data1.rdb) and second that upload data1.rdb 5-10 min later. Reason is that it may be possible the crontab to start at the same time as Redis save process.
Because topic is interesting, I may do simple script that do this, check http://redis4you.com/articles.php tomorrow.
精彩评论