Link Search Menu Expand Document

Redis CLI

Executing batches of commands using redis cli

Using heredoc works well here, if you don't want to use echo or explicitly add \n or create a new file

redis-cli <<EOF
set foo bar
get foo
EOF
OK
"bar"

Backup

redis-cli CONFIG get dir
1) "dir"
2) "/var/lib/redis"
redis-cli SAVE
OK

This will create a dump.rdb file in Redis directory (/var/lib/redis).

Restore

Move dump.rdb into Redis directory and start the server