All Products
Search
Document Center

Tair:Use data flashback to restore data by point in time

Last Updated:Sep 12, 2023

After the data flashback feature is enabled for an instance, the entire instance or keys of the instance can receive a point-in-time recovery (PITR) accurate to the second from an unexpired backup file. You can restore data to a new instance or the original instance. Such a refined data restoration capability can prevent data loss caused by accidental operations to the greatest extent.

Prerequisites

  • Cloud-native (cloud disk-based) deployment mode: An DRAM-based or persistent memory-optimized instance is created.

  • Classic (local disk-based) deployment mode: An DRAM-based instance that uses the standard or cluster architecture is created.

Note

To view the architecture of an instance, you can log on to the console and check the Instance Type parameter.

Data flashback overview

To protect your business data in the cloud, Tair provides the data flashback feature in addition to the data backup and restoration features based on Redis Database (RDB) snapshots. The data flashback feature optimizes append-only-file (AOF) persistence to allow AOFs to be incrementally archived. This way, data can be restored to a point in time accurate to seconds. This facilitates O&M and allows you to use Tair for persistent storage.

After the data flashback feature is enabled, you can restore the data of an instance or a specified key to a point in time that is accurate to seconds from an unexpired backup file. The maximum retention period of backup files is seven days. You can restore data to a new instance or the original instance. Such a refined data restoration capability can prevent data loss caused by accidental operations to the greatest extent.

Note

If you restore data to the original instance, the key that you want to restore is written back to the instance, which may increase the queries per second (QPS) or latency of the instance. We recommend that you restore data during off-peak hours.

Figure 1. Two modes of data flashback数据闪回两种模式

Limits

  • After you enable the data flashback feature, the system immediately uploads related data and logs. In this case, you must enable the feature in advance.

  • You can restore data only to a specific point in time that is in the time range from when data flashback is enabled to the current time. This period can be up to seven days.

  • After the data flashback feature is enabled, the point in time for data backup may change or the feature may be disabled due to the following operations:

    • If you change the architecture of an instance (such as from standard to cluster) or migrate the instance to another zone, date flashback is disabled for the instance. To use data flashback, you must re-enable the feature.

    • If you add a data shard to or remove a data shard from a cluster instance, data inconsistency may occur on the backup data. In this case, you must re-enable the feature.

    • If you change the configurations or minor version of an instance, you can restore data only to a time point later than the time point when the change is complete.

  • For cloud-native (cloud disk-based) instances, only full data can be restored. You cannot restore specified keys.

Billing

During the trial period of the data flashback feature, you can restore data to a point in time within the last seven days free of charge. After the official release, this feature is charged based on points in time of restoration. For more information, see this topic or the announcement on the Alibaba Cloud website.

Note

If you use the data flashback feature to restore data to a new instance, the system creates an instance and restores data to the instance. You must pay for the new instance. You can set the billing method of the new instance to pay-as-you-go and release the instance after it is no longer needed. For more information, see Billable items.

Enable the data flashback feature

  1. Log on to the Tair console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage resides. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane, click Backup and Recovery.

  3. On the Backup and Recovery page, click the Data Flashback tab.

  4. Click Enable Now.

    After you enable the data flashback feature, it takes a specific amount of time for the system to upload data and logs before you can use the feature. The console displays an expected point in time when the upload is complete.

    Important

    You can restore only data that is written to the instance after data flashback is enabled.

Perform data flashback

  1. Log on to the Tair console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage resides. Then, find the instance and click the instance ID.

  2. In the left-side navigation pane, click Backup and Recovery.

  3. On the Backup and Recovery page, click the Data Flashback tab.

  4. Click Start Flashbacking. In the dialog box that appears, set the parameters described in the following table.

    Parameter

    Description

    Data Flashback

    • Full Data: All data on the instance is restored.

    • Specified Keys: Specify one or more keys whose data you want to restore. Each key name occupies a line. You can specify regular expressions based on the following rules:

      • Period (.): matches a single character except '\r\n'.

      • Asterisk (*): matches zero or more occurrences of a preceding subexpression. For example, h.*llo matches hllo or heeeello.

      • Question mark (?): matches zero or one occurrence of a preceding subexpression. For example, h.?llo matches hllo or hello.

      • Character set [Characters]: matches a character included in brackets [ ]. For example, h[ae]llo matches hallo or hello.

      • Negative character set [^Characters]: does not match a character in brackets [ ]. For example, h[^ae]llo matches hcllo or hdllo, but not hallo or hello.

      • Character range [Character1-Character2]: matches a character in the range of Character1 to Character2. For example, h[a-b]llo matches hallo and hbllo.

      Note

      To ensure the efficiency of data restoration, we recommend that you specify no more than 10 keys or specify no more than three keys that use regular expressions.

    Restore Mode

    • New Instance: restores data to a new instance.

    • Original Instance: restores data to the current instance.

      Warning

      You can restore data to the original instance only if you set Data Flashback to Specified Keys.

      The specified keys are deleted. Tair restores the specified keys to the specified time point from the backup file. This has no impact on other keys in the instance.

    Flashback Time Point

    The point in time to which you want to restore data.

    Handle Expired Keys

    • Default: No operations are performed on the expiration time of keys. If a key expires before you submit the data restoration task, the key cannot be restored.

    • Time Offset: specifies the expiration offset time point of a key. You must also specify the Offset Time parameter. The key expires after the remaining validity period of the key elapses based on the expiration offset time point.

      For example, assume that you restore the foo key at 10:30 on December 12, 2022 and set Flashback Time Point to December 12, 2022, 10:00:00, and the remaining validity period of the foo key is 10 seconds. In this case, if you set Offset Time to December 12, 2022, 10:30:00, the foo key expires at 10:30:10 on December 12, 2022.

      Note

      The offset time point must be between the specified flashback time point and the time when the data restoration task is submitted.

  5. Click OK.

    • If you set the Restore Mode parameter to Original Instance, the current instance enters the Restoring state. Wait until the instance state changes to Running.

    • If you set the Restore Mode parameter to New Instance, the Clone Instance page appears. You must specify the point in time to which you want to restore data and the configurations of the new instance on this page.

      Note

      The new instance must be of the standard or cluster architecture, and the capacity of the new instance must be greater than or equal to that of the current instance. For more information about instance parameters, see Create a Tair instance.

Related operations

Operation

Description

ModifyBackupPolicy

Modifies the automatic backup policy of an instance of Tair. You can use the EnableBackupLog parameter to enable or disable the data flashback feature.

To use the data flashback feature, you must set the appendonly parameter to yes to enable append-only file (AOF) persistence. For more information, see Parameters that can be configured for Tair.

RestoreInstance

Restores the data of an instance of Tair from a backup file to the instance. If you use this operation together with the data flashback feature, you can restore data of a specified key to a specified point in time that is accurate to seconds.