在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
示例 目标:把服务器CentOS上的redis数据复制到Mac机上 步骤: 在CentOS上找dump文件位置 vi /etc/redis.conf dbfilename dump.rdb dir /var/lib/redis 说明文件在 /var/lib/redis/dump.rdb 在mac上查找dump文件位置 vi /usr/local/etc/redis.conf dbfilename dump.rdb dir /usr/local/var/db/redis 拷贝服务器上的dump.rdb到mac机器 scp root@dv:/var/lib/redis/dump.rdb ./ 在mac上重启Redis launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.redis.plist launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
#! /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!" 有如上脚本,便可以cron等方式备份redis数据文件了。细节如下: # The filename where to dump the DB dbfilename dump.rdb # The working directory. # # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration directive. # # Also the Append Only File will be created inside this directory. # # Note that you must specify a directory here, not a file name. dir /var/lib/redis/6379 |
请发表评论