This is from just a single memcached server with around 20M keys (no expiry) and around 2G of data.
What\'s the easiest way to get a dump of all the key/value pairs
Here is the script which I'm using to dump all the objects into corresponding files:
while read -r key; do
[ -f "$key" ] || echo "get $key" | nc localhost 11211 > "$key.dump";
done < <(memcdump --server localhost)
It uses memcdump command which should be part of memcached utils.
For compressed objects, see: How to dump a compressed object for given key from Memcache?
To dump a list of keys from a server, use memcdump/memdump tool, e.g.
memcdump --servers=localhost | tee my_keys.lst
To print the value of one item, use netcat:
echo "get 13456_-cache-some_object" | nc localhost 11211
To dump all objects into the screen via memcdump/memdump and netcat:
memcdump --servers=localhost | xargs -L1 -I% sh -c 'echo "get %" | nc localhost 11211'
In the recent version of memcached there is also memcached-tool command, e.g.
memcached-tool localhost:11211 dump | less # dumps keys and values