ApsaraDB for MongoDB instances support the key-based flashback feature. The feature allows you to back up a specific data collection, which enhances data archiving and quick restoration based on a flashback key when the data is disordered or lost due to system vulnerabilities or faults. By default, the flashback key is _id.
The key-based flashback feature has been in public preview since February 26, 2024. You are not charged during public preview. The service level agreement (SLA) of the feature is not guaranteed during public preview.
Prerequisites
A replica set or sharded cluster instance is created.
The storage type of the instance is cloud disks.
The major version of the instance is MongoDB 5.0 or later.
The key-based flashback feature is in public preview. To use the feature, contact technical support.
Usage notes
The key-based flashback feature may compromise the instance performance. For example, the TPS performance of the instance may decrease by up to 3%.
The preceding degraded instance performance value is for reference only. The actual data shall prevail.
Feature description
Feature | Item | Description |
Task configuration | The time when the flashback task takes effect after the configuration is complete | 10 minutes. |
Retention duration of flashback data | 1 to 7 days. | |
Restoration time of flashback data | The duration from the time when the feature is enabled to the current time. During the retention period of flashback backups, you can perform flashback by key based on the specified time and row ID. | |
Flashback backup | Supported flashback operations |
|
Supported row-based index types |
| |
Data types that support indexes | Only the following data types are supported:
| |
Index fields | The field name can contain only letters, digits, and underscores (_). The name must start with a letter or an underscore (_). | |
Length and number of indexes | An index is 128 characters in length. The number of indexes is limited to 10. | |
Maximum index size during query | The maximum index size is 16 KB. No data is returned if you query data that exceeds 16 KB in size. | |
Data size of a single row in query results | No limits. | |
Flashback restoration | Maximum number of rows restored in a single flashback | The maximum number is 1,000. Rows are truncated if the number of the rows to be restored in a flashback exceeds 1,000. |
Flashback data preview | The index keys to be restored and previewed must be less than 48 KB in size. | |
Database and collection name settings | The names of a database and a collection are 254 characters in length. For example, the names of a database (test) and a collection (table) are displayed as |
Billing rules
You are not charged for the use of the key-based flashback feature during public preview.
Enable the key-based flashback feature
Go to the Replica Set Instances or Sharded Cluster Instances page. In the top navigation bar, select the region in which the instance resides. Then, find the instance and click the ID of the instance.
In the left-side navigation pane of the instance details page, click Backup and Restoration.
Click the Flashback by Key tab.
Click Flashback Backup Settings.
NoteAfter you perform this operation, the You do not have the required permissions. message may appear. You must enter an account and a password. The account must have read/ write permissions on the database to be flashed back. For more information about database accounts and their permissions, see (Optional) Create a database account and grant permissions.
In the Flashback Backup Settings dialog box, configure parameters described in the following table and then click OK.
Parameter
Description
Retention Period for Backup files
The retention period of backup files. Valid values: 1 to 7. Unit: day.
For example, if you set the parameter to 1, the system starts timing after flashback backup files are generated and automatically deletes the backup files one day later.
Select Table to be Backed up
The collection to be backed up.
Preview and Configure Indexes in Table to be Backed up
Indexes in the collection to be backed up. Default value:
_id
. Multiple indexes are separated by commas (,).You can specify a maximum of 10 indexes.
In the Modify Flashback Backup Settings dialog box, click OK.
Initiate a flashback task
On the Flashback by Key tab of the Backup and Restoration page, click Flash back Data by Time Point in the Actions column corresponding to the backup task that you want to manage.
In the panel that appears, configure the parameters described in the following table and then OK.
Parameter
Description
Select Table to be Restored
No modification is required.
Create Temporary Table
The temporary collection that stores flashback data.
Select Time Point for Restoration
The time point to which you want to flash data back.
Enter Key to be Restored
Separate multiple primary keys with semicolons (;).
For example, if the index is _id and the keys to be restored are key1 and key2, you must enter
key1;key2
in the field.[ { "_id": "key1" }, { "_id": "key2" } ]
is displayed in the Index Key Restoration Preview section.You can use the
column=value
syntax to specify a column for queries.For example, if you enter
key1;test1=v1,key2
in the field,[ { "_id": "key1" }, { "test1": "v1", "_id": "key2" } ]
is displayed in the Index Key Restoration Preview section.If a primary key contains commas (,) or semicolons (;), escape them with escape characters (\).
For example, if the primary key is
a,b
, you must entera\,b
in the name field.
NoteIf the value of this parameter is excessive characters in length, the system automatically splits the task that you want to initiate into multiple flashback subtasks. This does not affect the flashback backup.
In the Data Flashback Preview dialog box, select data that you want to flash back and then click OK.
After a flashback task is initiated, the flashback data is stored in a temporary collection. During the validity period of the temporary collection, you can restore the data in the temporary collection to the original collection. The validity period indicates the backup retention period specified when you enable the flashback backup feature.
Restore data to the original collection
On the Flashback by Key tab of the Backup and Restoration page, click the + icon on the left side of the backup task that you want to manage.
Click Restore to Original Table.
In the Restore to Original Table dialog box, click OK.
NoteThis operation restores data in a temporary collection to the original collection and overwrites data in the original collection.
The overwrite operation takes about 1 to 2 minutes. During this period, do not write the same key. Otherwise, the restored data may not meet your expectations.
You can click Flashback Records to view all flashback backup tasks and restore the data to be flashed back to the original collection. You can also click Restoration Task Records to view all flashback backup tasks.
Disable one or more flashback backup tasks
Disable a flashback backup task
On the Flashback by key tab of the Backup and Restoration page, find the backup task that you want to disable and then click Disable in the Actions column.
Disable all flashback backup tasks
On the Flashback by Key tab of the Backup and Restoration page, click Disable Flashback Backup in the upper-left corner.