redis: backing up dump.rdb

2019-03-14 13:15发布

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!

标签: redis
2条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-14 14:13

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.

查看更多
时光不老,我们不散
3楼-- · 2019-03-14 14:15

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

查看更多
登录 后发表回答