All Products
Search
Document Center

ApsaraDB for Redis:How do I restore an on-premises RDB file to an ApsaraDB for Redis instance?

Last Updated:Feb 07, 2024

An on-premises Redis Database (RDB) file can be restored to an ApsaraDB for Redis instance. To accomplish this, you first need to restore the RDB file to a self-managed Redis database, and then migrate data from the self-managed Redis database to the ApsaraDB for Redis instance.

Procedure

  1. Create an ApsaraDB for Redis instance. For more information, see Step 1: Create an ApsaraDB for Redis instance. If you already have an ApsaraDB for Redis instance, skip this step.

  2. Restore the on-premises RDB file to a self-managed Redis database.

    Important
    • If an RDB file already exists in the directory (dir) specified in the Redis configuration file (redis.conf), back up the existing RDB file before you migrate the new RDB file to prevent accidental loss of existing data.

    • If append-only file (AOF) persistence is enabled for the self-managed Redis database, the AOF is used in preference to restore data upon service restart. This may prevent the data in the RDB file from being successfully restored to Redis. In this case, disable AOF persistence. If the AOF in the specified directory (dir) has been backed up to another directory, you can then restart Redis. If you want to enable AOF persistence again after Redis is restarted, you can run the redis-cli CONFIG SET appendonly yes command. After the command is run, Redis creates a new AOF in the specified directory and writes the data currently in memory to the new AOF. However, this configuration applies only to the currently running Redis database. To permanently enable AOF persistence, set appendonly to yes in the Redis configuration file (redis.conf).

    1. Move the RDB file to the specified directory (dir) in the Redis configuration file (redis.conf).

    2. Modify the name of the RDB file so that it is the same as the file name (dbfilename) specified in the Redis configuration file (redis.conf).

    3. Restart the self-managed Redis database.

    4. Query Redis data and check that the data in the RDB file has been restored to the self-managed Redis database.

  3. Use Data Transmission Service (DTS) to migrate data from the self-managed Redis database to the ApsaraDB for Redis instance. For more information, see Migrate data from a self-managed Redis database to an ApsaraDB for Redis instance.

References

For information about how to restore AOFs from self-managed Redis databases to ApsaraDB for Redis instances, see Use AOF files to migrate data.