Redis data Backup and Recovery methods

Source: Internet
Author: User
This article we share with you a simple and rough redis data backup and recovery method, there is an example of migrating Redis data on different hosts, and a key point of backup script implementation, hoping to help everyone.

Example

Goal: Copy Redis data from a server CentOS to a Mac machine

Steps:

Find the dump file location on CentOS


Vi/etc/redis.confdbfilename Dump.rdb Dir/var/lib/redis

The description file is


/var/lib/redis/dump.rdb

Find the dump file location on your Mac


Vi/usr/local/etc/redis.confdbfilename Dump.rdb Dir/usr/local/var/db/redis

Copy the Dump.rdb on the server to the Mac machine


SCP Root@dv:/var/lib/redis/dump.rdb./

Restart Redis on Mac


Launchctl unload ~/library/launchagents/homebrew.mxcl.redis.plist launchctl load ~/library/launchagents/ Homebrew.mxcl.redis.plist


PS: Backup Script
Look at the following script,


#! /bin/bashpath=/usr/local/bin: $PATHredis-cli savedate=$ (date + "%y%m%d") cp/var/lib/redis/6379/dump.rdb/data01/ cache_backup/$date. Rdbecho "done!"

Like a script, you can back up Redis data files in a cron way. Details are as follows:
You must first save, because Redis's Rdb file is not always a full image of the memory data, it must be save before backup, that is, send the Save command, and then copy the Rdb file.
The specific path to the RDB is not necessarily the same as above, and can be found in the Redis configuration file,/etc/redis/6379.conf


# the filename where to dump the Dbdbfilename dump.rdb# the working directory.## the DB would be Written inside this directory, with the filename specified# above using the ' dbfilename ' configuration directive.## Also t He Append only file would be created inside this directory.## Note so you must specify a directory here, not a File name. dir/var/lib/redis/6379 

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.