Simple, crude Redis data Backup and Recovery methods _redis

Source: Internet
Author: User
Tags redis

Example

Objective: To copy the Redis data on the server CentOS to the Mac

Steps:

Find the dump file location on the CentOS

vi/etc/redis.conf
dbfilename Dump.rdb 
Dir/var/lib/redis

Description file in

/var/lib/redis/dump.rdb

Locating the dump file location on the Mac

vi/usr/local/etc/redis.conf


dbfilename 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 the Redis on the 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/bash

path=/usr/local/bin: $PATH
redis-cli SAVE

date=$ (date + "%y%m%d")
cp/var/lib/redis/6379/ dump.rdb/data01/cache_backup/$date. Rdb

echo "done!"

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

# The filename where to dump the DB
dbfilename Dump.rdb

# The working directory.
#
The DB'll is written inside this directory, with the filename specified
# above using the ' dbfilename ' con figuration directive.
#
# Also The Append only File would be created inside this directory.
#
# That's you must specify a directory, not a file name.
dir/var/lib/redis/6379

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.