Migrating from rdb versions 2 -> 1

501 views
Skip to first unread message

SimonW

unread,
Apr 17, 2012, 8:01:42 AM4/17/12
to Redis DB
Hello all,

I have a redis instance in one location running Redis 2.4.8, and
another in a different location running Redis 2.0.3. There's no
network route between the two Redis instances.

I need to copy the data held on the 2.4.8 instance onto the 2.0.3
instance. I'd usually do this by simply issuing a SAVE on the 2.4.8
instance, then copying the dump file into the 2.0.3 instance.
However, the 2.0.3 instance complains that it:

"Can't handle RDB format version 2"

I surmise from my googling thus far that the rdb format has changed
between 2.0.3 and 2.4.8, so my destination Redis instance can't read
the datafile created by it's source.

Is there a way for me to convert the 2.4.8 dump file into a format
that my 2.0.3 instance will be able to read? I've got complete
control over the 2.4.8 instance if need-be.

Thanks in advance,

Simon

Pieter Noordhuis

unread,
Apr 17, 2012, 12:10:27 PM4/17/12
to redi...@googlegroups.com
This is not possible out of the box. Later versions store
space-optimized values, that can't be read by older versions. Why do
you want to restore a 2.4 database on a 2.0 instance?

Cheers,
Pieter

> --
> 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.
>

Sripathi Krishnan

unread,
Apr 17, 2012, 12:51:40 PM4/17/12
to redi...@googlegroups.com
> Is there a way for me to convert the 2.4.8 dump file into a format
> that my 2.0.3 instance will be able to read?  I've got complete
> control over the 2.4.8 instance if need-be.

You can try the following hack. It may or may not work, so please backup dump.rdb and redis.conf files.
  1. First, take backups
  2. In your 2.4 redis.conf, set the following properties to 0 
    hash-max-zipmap-entries, list-max-ziplist-entries, set-max-intset-entries
  3. Restart Redis, and issue the SAVE command
  4. Then, edit the dump.rdb file in a hex editor. The first 9 characters will be REDIS0002. Change that to REDIS0001. Leave the rest of the file intact.
  5. Copy the modified dump file to your 2.0 instance, and restart Redis
  6. Hopefully, it should load the file properly
When the dump file is loaded, Redis automatically converts lists/hashes/sets to the appropriate compressed format if applicable - so there isn't any memory/performance hit.

--Sri

P.S. You are better off upgrading Redis though.. 

Salvatore Sanfilippo

unread,
Apr 17, 2012, 12:54:42 PM4/17/12
to redi...@googlegroups.com
+1 about this, should work AFAIK.

Salvatore

--
Salvatore 'antirez' Sanfilippo
open source developer - VMware

http://invece.org
"We are what we repeatedly do. Excellence, therefore, is not an act,
but a habit." -- Aristotele

r043v

unread,
Apr 17, 2012, 3:57:02 PM4/17/12
to Redis DB
you can try my util, rdd, who can dump and restore redis data
independantly of the redis version (not use rdb files)
https://github.com/r043v/rdd/

SimonW

unread,
Apr 18, 2012, 4:31:49 AM4/18/12
to Redis DB
Thanks for the responses all.

I initially used rdd to do the job after misreading Sri's suggestion
but then realised what I'd done wrong, so can confirm both solutions
work!

Thanks again guys,

Simon

On Apr 17, 8:57 pm, r043v <nofe...@gmail.com> wrote:
> you can try my util, rdd, who can dump and restore redis data
> independantly of the redis version (not use rdb files)https://github.com/r043v/rdd/
Reply all
Reply to author
Forward
0 new messages