Skip to content

Instantly share code, notes, and snippets.

@jintao-zero
Last active April 1, 2017 07:11
Show Gist options
  • Save jintao-zero/65f4040d6991a520e0a988060348f550 to your computer and use it in GitHub Desktop.
Save jintao-zero/65f4040d6991a520e0a988060348f550 to your computer and use it in GitHub Desktop.
使用shell redis-cli命令迁移list类型数据
#!/bin/sh
if [ $# -lt 1 ]
then
echo $0 list-key
exit
fi
src_redis_host="dsff.redis.rds.aliyuncs.com"
src_redis_passwd="wwwww"
src_redis_db=15
dst_redis_host="r-.redis.rds.aliyuncs.com"
dst_redis_passwd="5555"
dst_redis_db=30
value=`redis-cli -h ${src_redis_host} -a ${src_redis_passwd} -n ${src_redis_db} lrange $1 0 -1`
#echo "${value}" #| redis-cli -h r-bp13f46238e92bd4.redis.rds.aliyuncs.com -a Vghva9EBzAf2r8 -n 30
for v in ${value}
do
echo "rpush $1 ${v}" | redis-cli -h ${dst_redis_host} -a ${dst_redis_passwd} -n ${dst_redis_db}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment