user1311390
user1311390

Reputation:

redis: backing up dump.rdb

Context

I have a live running redis-server.

I want to make a backup.

Idea:

I want to do the following:

cp dump.rdb ~/some-other-location/06-24-2012.rdb ?

Concern

I don't see anything that promises me that dump.rdb is always a consistent database store. (I.e. it appears possible to me that while I am executing cp, redis is halfway through writing some piece of data, and thus dump.rdb is not in a consistent state.)

Problem:

This is bad, because I will now have to shut down the redis db in order to make a copy of dump.rdb

Question:

What is the correct way, while a redis-server is running, to make a live backup of the database? And what part of the manual promises me that this method creates a database that is in a consistent (not half written) state.

Thanks!

Upvotes: 34

Views: 14713

Answers (2)

Seyhun Akyürek
Seyhun Akyürek

Reputation: 851

If you using Amazon S3, it's very simple to backup Redis database with s3cmd tool.

s3cmd: http://s3tools.org/s3cmd

Tutorial: http://guchex.com/viniciusfbm/post/50/how-to-backup-redis-database-encrypted-to-s3-via-command-line-ubuntu

Upvotes: 1

Sripathi Krishnan
Sripathi Krishnan

Reputation: 31538

From http://redis.io/topics/persistence

Redis is very data backup friendly since you can copy RDB files while the database is running: the RDB is never modified once produced, and while it gets produced it uses a temporary name and is renamed into its final destination atomically using rename(2) only when the new snapshot is complete.

So, the correct way is to simply copy the dump.rdb to your backup location.

Upvotes: 53

Related Questions