Safe way to backup an RDB file

456 views
Skip to first unread message

teleo

unread,
Jul 27, 2010, 3:31:27 AM7/27/10
to Redis DB
Hi,

In Mongo, to backup the database it is possible to lock the slave,
copy the files and then unlock the slave.

See: http://www.snailinaturtleneck.com/blog/2010/07/26/mongodb-backups-corn-on-the-cob-in-10-minutes/

What is the safest way to backup an RDB file in Redis?

Thanks,
T

Salvatore Sanfilippo

unread,
Jul 27, 2010, 3:39:02 AM7/27/10
to redi...@googlegroups.com
On Tue, Jul 27, 2010 at 9:31 AM, teleo <lev....@gmail.com> wrote:

> What is the safest way to backup an RDB file in Redis?

In Redis .rdb files can be copied while the server is running without
any need of lock. No corruption is possible since the new file is
always saved in a temp location and atomically rename(2)d to the new
location.

So just use "cp" :)

Cheers,
Salvatore

> Thanks,
> T
>
> --
> You received this message because you are subscribed to the Google Groups "Redis DB" group.
> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/redis-db?hl=en.
>
>

--
Salvatore 'antirez' Sanfilippo
http://invece.org

"Once you have something that grows faster than education grows,
you’re always going to get a pop culture.", Alan Kay

teleo

unread,
Jul 27, 2010, 5:22:50 AM7/27/10
to Redis DB
Thanks. Sounds great.

Just to clarify, what happens if while I am copying the RDB file, a
new file is renamed to overwrite the RDB? Isn't it possible that the
disk space formerly occupied by the old RDB will be reclaimed and used
by some other process? Or is it the case that while the file is open
by me, the space will not be reclaimed?

On Jul 27, 10:39 am, Salvatore Sanfilippo <anti...@gmail.com> wrote:
> On Tue, Jul 27, 2010 at 9:31 AM, teleo <lev.ko...@gmail.com> wrote:
> > What is the safest way to backup an RDB file in Redis?
>
> In Redis .rdb files can be copied while the server is running without
> any need of lock. No corruption is possible since the new file is
> always saved in a temp location and atomically rename(2)d to the new
> location.
>
> So just use "cp" :)
>
> Cheers,
> Salvatore
>
> > Thanks,
> > T
>
> > --
> > You received this message because you are subscribed to the Google Groups "Redis DB" group.> To post to this group, send email tored...@googlegroups.com.> To unsubscribe from this group, send email toredis-db+...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/redis-db?hl=en.
>
> --
> Salvatore 'antirez' Sanfilippohttp://invece.org

Bret A. Barker

unread,
Jul 27, 2010, 10:08:43 AM7/27/10
to redi...@googlegroups.com
Your 'cp' will have an open file handle on the old/existing .rdb, so it's safe.
-bret

> To post to this group, send email to redi...@googlegroups.com.
> To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.

David

unread,
Jul 28, 2010, 1:21:11 AM7/28/10
to Redis DB
Can an AOF file be backed up with a simple 'cp' command? Or must we
create a dump file to do a backup?

Thanks,
David

On Jul 27, 3:39 pm, Salvatore Sanfilippo <anti...@gmail.com> wrote:
> On Tue, Jul 27, 2010 at 9:31 AM, teleo <lev.ko...@gmail.com> wrote:
> > What is the safest way to backup an RDB file in Redis?
>
> In Redis .rdb files can be copied while the server is running without
> any need of lock. No corruption is possible since the new file is
> always saved in a temp location and atomically rename(2)d to the new
> location.
>
> So just use "cp" :)
>
> Cheers,
> Salvatore
>
> > Thanks,
> > T
>
> > --
> > You received this message because you are subscribed to the Google Groups "Redis DB" group.
> > To post to this group, send email to redi...@googlegroups.com.
> > To unsubscribe from this group, send email to redis-db+u...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/redis-db?hl=en.
>
> --
> Salvatore 'antirez' Sanfilippohttp://invece.org

David

unread,
Aug 11, 2010, 3:30:57 AM8/11/10
to Redis DB
Hi guys, is anyone able to help me out? I'd just like to know the
proper way to backup a Redis instance that is using AOF rather than
snapshotting. Do I still need to do a snapshot for a backup, or can I
just copy the AOF file?

Thanks,
David

On Jul 28, 1:21 pm, David <edgebo...@gmail.com> wrote:
> Can an AOF file be backed up with a simple 'cp' command? Or must we
> create a dump file to do a backup?
>
> Thanks,
> David
>
> On Jul 27, 3:39 pm, Salvatore Sanfilippo <anti...@gmail.com> wrote:
>
>
>
> > On Tue, Jul 27, 2010 at 9:31 AM, teleo <lev.ko...@gmail.com> wrote:
> > > What is the safest way tobackupan RDB file in Redis?
Reply all
Reply to author
Forward
0 new messages