Can a Redis instance be configured to NOT overwrite old snapshots?

Viewed 39

Currently I am using the redis.conf file to provide the fixed directory and filename to my instance to save the redis dump.rdb snapshot.

My intention is to compare two redis snapshots taken at different times. But Redis rewrites over the old dump file after creating the new one.

I checked the redis repo on github and found the rdb.c file, which has the code that executes the SAVE commands and rewrites over old snapshots.

Before messing with code(since i'm not an experienced developer), I wanted to ask if there is a better way to save snapshots taken at different times? Or if I could just save the last 2 snapshots at a time?

1 Answers

You can use incron to watch the dump directory and execute a script

sudo apt-get install incron
echo "redis" >> /etc/incron.allow

export EDITOR=vi
incrontab -e

/path/where/you/dump/files IN_CLOSE_WRITE,IN_CREATE,IN_DELETE /bin/copy_snapshot

then create a /bin/copy_snapshot script file rename it with a date or something and make sure there are X number of copies

Related