Redis Database backup Script

Source: Internet
Author: User

Redis-dump Command installation environment refer to the link address:
http://blog.51cto.com/wujianwei/2105124

Redis Database backup script:

[Email protected] ~]# cat/data/scripts/dump_redisdata.sh

#!/bin/bashsource /etc/profile.d/rvm.sh/usr/local/rvm/bin/rvm --create ruby-2.3.4 & >/dev/nullDATENOW=`date +%Y%m%d`DIR=/data/backup/redisdb/"$DATENOW"DATETIME=`date +%H%M`if [ ! -d "$DIR" ] then    mkdir -p  /data/backup/redisdb/"$DATENOW"fi/usr/local/rvm/gems/ruby-2.3.4/bin/redis-dump -u 127.0.0.1:6379 >"$DIR"/redis$DATETIME-jsonoldDate=$(date -d "-6 days" "+%Y%m%d")cd /data/backup/redisdb for folder in $(ls -d */)do   [ ${folder%/*} -lt $oldDate ] && rm -rf $folderdone

[Email protected] 20180608]# pwd
/data/backup/redisdb/20180608

The contents of the backed up data are as follows:

[[email protected] 20180608]# tail -2 redis1230-json{"db":0,"key":"/a","ttl":-1,"type":"string","value":"http://www.jd.com","size":17}{"db":0,"key":"/b","ttl":-1,"type":"string","value":"http://www.51cto.com","size":20}

Redis Database backup Script

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.