×
Community Blog Data Recovery - How to Use "Data Flashback" on ApsaraDB for Redis to Recover Data by Time Point

Data Recovery - How to Use "Data Flashback" on ApsaraDB for Redis to Recover Data by Time Point

This article explains how to use "data flashback" on ApsaraDB for Redis to recover data at a specified time point.

In the data era, business data is the core asset for enterprises. Customers in various industries are constantly seeking more powerful and fine-grained data backup and recovery capabilities in their databases. With these capabilities, they can address commercial risks caused by data loss and business logic errors. For example, in the gaming industry, a large number of customers demand the "game correction" capability to cope with the risk of operation or failure. Another example, in 2020, an employee of a listed company destroyed the company's data. As a result, the market value of the company was severely affected. Conventional scheduled or manual data backups are not ideal solutions for the preceding incidents. Data backup and "black swan" incidents (abnormal incidents that are hard to predict) happen at different times. To prevent the incidents above, the ideal solution is to use second-level granularity. The data can be recovered to the time point when the "black swan" incident happened.

Alibaba Cloud provides data flashback for traditional relational databases, such as Oracle to recover data by time point. However, similar functions are seldom provided for mainstream cache products like Redis and Memcached. As a cache product, the data in it can be lost without major repercussions. Users can reload the cache through the persistent and transactional relational databases deployed in cache products. However, as many customers increasingly require high-performance applications with low latency, they are choosing to simplify their architectures in scenarios with extreme requirements for low latency, such as the gaming industry. They use Redis as a main memory database, which brings a greater challenge to the data security and data recovery in Redis. As a leading product in the industry, ApsaraDB for Redis has powerful products in China. While managing the Redis Community Edition, Alibaba Cloud is also striving to independently develop enhanced key-value storage products, namely Tair. Tair is the enhanced edition of Redis and is compatible with Redis protocols.

"Higher security" is an important feature of services that ApsaraDB for Redis provides to customers. To satisfy the demands of customers, Alibaba Cloud has added "data flashback" in the enhanced edition of Tair. By doing so, Tair can help customers recover the data of specified Redis instances at specified time points. Thus, customers can recognize possible risks and be prepared in advance. The process of data recovery through data flashback is shown in the pictures below:

1

It takes only a few steps for customers to recover their data regardless of data changes through data flashback.

  • Activate the enhanced instance of Redis Enterprise Edition
  • Click to start the data flashback
  • Read and write data in your Redis database
  • Once the instant data recovery requirement occurs, users can create a new instance by selecting the corresponding instance and the time for data recovery
  • Change the instance address where an application is connected.

Here is a simple example:

First, write some data to Alibaba Cloud's Tair instance by using the following script:

% cat preparerepldata.sh
#!/bin/bash
 
echo "started at: `date +%m%d%H%M%S`"
for i in `seq -f "%010g" 1 $1`
do
    namerand=$[ $RANDOM % 3 ]
    timerand=`date +%m%d%H%M%S`
    nationrand=$[ $RANDOM % 3 ]
    redis-cli -h   r-t4nq2viog3z4rshoxxpd.redis.singapore.rds.aliyuncs.com -a 'gnuhpc:Pa$$w0rd'   hset userprofile foo$timerand $namerand
    sleep 0.75 #consider the   latency for connection establish
done
 
echo "ended at:   `date +%m%d%H%M%S`"

Run the script above to write time-stamped Key-Values (KV) to a hash structure called userprofile at a rate of about one KV per second, with a total of 120 keys. This represents service writing.

% bash preparerepldata.sh   120
OK
OK
…
 
% redis-cli -h hosts -a 'username:password'   hkeys userprofile | wc -l
     120
% redis-cli -h hosts -a 'username:password'   hkeys userprofile | sort -n
foo0803202709
…
foo0803202909

As seen above, 120 data records were written between 20:27:09 on August 3 and 20:29:09 on August 3.

Then, it was found that data risks occurred in the above-mentioned business operation after 20:28:10 on August 3. In this situation, we need to create a new database instance and recover the data of the original database before 20:28:10 on August 3 to the new database instance.

We use the ApsaraDB for Redis console for data backup and recovery. First, select "data flashback" and click the "flashback now" button. Then, select the "time point of the past" as the clone source type, and choose the specified time point to recover data:

2

The newly created instance is the target instance where recovered data at a specified time will be stored. The data flashback only requires the target instance capacity to be greater than or equal to the source instance, while the architectures of both instances can be different. In other words, users are free to regard target instances with different architectures as a standard client-server, cluster, or read/write splitting architecture.

After clicking the "pay" button, users have to wait a few minutes before the creation of the instance and the recovery of data is complete.

Let's check the newly created instance and see how the data recovery going:

% redis-cli -h hosts -a 'username:password'   hkeys userprofile | wc -l
62

% redis-cli -h hosts -a 'username:password'   hkeys userprofile | sort -n
foo0803202709
…
foo0803202810

It shows that the data has been successfully recovered to its status at 20:28:10 on August 3, and the data modifications after this time point have not taken effect. This perfectly helps users avoid data risks that occurred after the specified time point.

As the world's leading database enterprise, the core ideas of Alibaba Cloud's database are Faster, Stronger, and Securer. Alibaba Cloud's database is committed to providing users with database products characterized by ultimate performance, high stability, high security, and reliability. To practice the core idea of "Securer", data flashbacks provided by Alibaba Cloud for Tair supports data recovery at a specified time point in a second-level. With this feature, the precious data assets of customers can be highly protected. Customers can also be more confident in simplifying architecture and fast iteration of business, taking Redis as a main memory database. Redis is also supported by MyBase, a dedicated cluster of cloud databases, which is the customized and optimized solution provided by Alibaba Cloud for large and medium-sized enterprises. Characterized by exclusive resources, independent O&M, and the hybrid deployment of multi-databases, this solution fills the gap in the market. It enables users to enjoy the flexibility of cloud databases while meeting their requirements for compliance, high performance, and security of databases.

Users no longer need to worry about data loss! With data flashback provided by ApsaraDB for Redis Enhanced Edition, users can recover the data of specified Redis instances at a specified time point. For more information, see https://www.alibabacloud.com/help/product/26340.htm

0 0 0
Share on

ApsaraDB

76 posts | 6 followers

You may also like

Comments

ApsaraDB

76 posts | 6 followers

Related Products