Taking a backup with Redis

Taking a backup of the current state of a Redis instance is a fairly simple matter. It involves forcing the contents of RAM to be persisted to disk and copying the resulting dump.rdb file to another location.

First, let's check the last time the contents of our Redis instance were written to disk. We can do that with the lastsave command in the redis-cli:

127.0.0.1:6379> lastsave
(integer) 1501703515

This command returns the UNIX epoch timestamp of the last time the instance's data was persisted to disk.

The UNIX epoch time is the number of seconds that have elapsed since January 1, 1970.

Next, let's ensure that the contents of our Redis instance have been written to disk. We can do that with the bgsave command ...

Get Seven NoSQL Databases in a Week now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.