You can use the dump mode of the redis-shake tool to back up the data of an ApsaraDB for Redis instance to an RDB file.
Prerequisites
- A database account that has the Replicate permission is created for an ApsaraDB for Redis instance. For more information about how to create a database account, see Manage database accounts.
- The architecture of the ApsaraDB for Redis instance is the standard edition or single-node read/write splitting edition.
- The version of the ApsaraDB for Redis instance is Redis 4.0.
- An Elastic Compute Service (ECS) instance is created for running the redis-shake tool.
- The IP address of the ECS instance is added to the whitelist of the source ApsaraDB for Redis instance.
- The ECS instance is running the Linux operating system.
- The remaining disk space in the ECS instance is larger than the space required by the RDB file to be generated.
Background
The redis-shake tool is an open-source tool developed by Alibaba Cloud. You can use it to parse (decode mode), recover (restore mode), back up (dump mode), and synchronize (sync/rump mode) Redis data. In dump mode, the redis-shake tool can back up the data of a Redis database to an RDB file, which can be used to recover or migrate data. This topic describes how to use the dump mode of the redis-shake tool to back up the data of an ApsaraDB for Redis instance to an RDB file.
- The redis-shake tool can use an RDB file to recover or migrate data. For more information, see Use the redis-shake tool to migrate data from an RDB file.
- For more information about the redis-shake tool, see redis-shake on GitHub or FAQ.
Procedure
- Log on to the ECS instance that can access the source ApsaraDB for Redis instance.
- Download the redis-shake tool in the ECS instance.
Note We recommend that you download the latest version.
- Run the following command to decompress the downloaded
redis-shake.tar.gz
package:tar -xvf redis-shake.tar.gz
Note In the decompressed folder, the redis-shake file is a binary file that can be run in the 64-bit Linux operating system. The redis-shake.conf file is the configuration file of the redis-shake tool. You need to modify this configuration file in the next step. - Modify the redis-shake.conf file. The following table describes the parameters for
the dump mode of the redis-shake tool.
Table 1. Parameters for the dump mode of the redis-shake tool Parameter Description Example source.address The connection address and service port of the source ApsaraDB for Redis instance. xxxxxxxxxxxx.redis.rds.aliyuncs.com:6379 source.password_raw The password of the source ApsaraDB for Redis instance. account:password rdb.output The name of the RDB file to be generated. local_dump - Run the following command to back up data:
./redis-shake -type=dump -conf=redis-shake.conf
Note You must run this command in the same directory as the redis-shake and redis-shake.conf files. Otherwise, you need to specify the correct file path in the command.Note- When
execute runner[*run.CmdDump] finished!
appears in redis-shake logs, the data is backed up to the RDB file. - The name of the RDB file is
local_dump. 0
by default. You can run thecat local_dump. 0
command to check whether Redis data is backed up.
- When
(Optional) Next step
Use the RDB file to recover data to the destination ApsaraDB for Redis instance. For more information, see Use the redis-shake tool to migrate data from an RDB file.