11

I realize that all my data is gone when I log in... KEYS * shows nothing.

Luckily, I'm doing this in dev server.

What am I supposed to do if this happens in the future on production?

Am I supposed to back it up every second?

user847495
  • 9,831
  • 17
  • 45
  • 48

2 Answers2

24

You can find a number of answers/options here:

http://redis.io/topics/persistence

From what I could gather, you should:

  1. Configure your server instance to periodically persist its data to file every 5 minutes or so. That way at most you will lose a few minutes of data if the server goes down.
  2. Configure your server instance to write an AOF redo log (append-only-file). You have various options to favor durability or performance.
  3. Add at least one additional server and use that for replication. That way you will only ever lose any data if both/all of the servers go down simultaneously.
Didier Spezia
  • 70,911
  • 12
  • 189
  • 154
aroth
  • 54,026
  • 20
  • 135
  • 176
6

Redis is not the most durable way to store your data. With journaling mode your data is written to disk but you could still lose some data in the event of a crash.

Are you sure you have picked up the right solution for your service? Seems like you need something else than redis?

See also this; Is redis a durable datastore?

Community
  • 1
  • 1
veturi
  • 1,971
  • 2
  • 13
  • 17