Archive data to dedicated storage
This topic describes how to use Data Management (DMS) to archive data to dedicated storage and how to delete the archived data.
Data archiving is currently in public preview.
Prerequisites
The source database is one of the following types:
MySQL: ApsaraDB RDS for MySQL, PolarDB for MySQL, or AnalyticDB for MySQL V3.0.
NoteThe account used to connect to the MySQL database must have the REPLICATION CLIENT permission.
PostgreSQL: ApsaraDB RDS for PostgreSQL or PolarDB for PostgreSQL.
MongoDB 3.6 or later.
NoteAfter data from MongoDB is archived to dedicated storage, you can only query the data. You cannot restore the data to MongoDB.
You can no longer configure new data archiving tasks that use MongoDB as a source database.
The control mode of the source database is Stable Change or Security Collaboration.
NoteIf the control mode of your instance is Stable Change and you want to perform periodic archiving, we recommend that you enable security hosting for the instance or change its control mode to Security Collaboration. This prevents task failures caused by an expired instance logon. For more information, see Enable security hosting and Change the control mode of an instance.
Source tables must have a primary key or a unique key.
NoteWe recommend that your source tables include a field that indicates the modification time of business data. You can use this field as a filter condition for data archiving.
Billing
This feature is free during the public preview. You will be notified in advance if this feature becomes a paid service.
Usage notes
There is no storage limit for data archived to dedicated storage.
If a source table has a composite primary key that consists of three columns or has three or more unique keys, the archiving task may fail. Fully test these source tables before archiving, or consider other methods, such as Database Backup Service (DBS).
If you archive data from an ApsaraDB for MongoDB database, the structure of the archived data may have issues. We recommend that you validate and fix the archived data before you clean up the temporary tables.
When MongoDB data is archived to dedicated storage, the unstructured data is converted into structured data. To ensure that you can successfully query the data from dedicated storage after archiving, you must verify that all documents in the same MongoDB Collection have consistent field names, number of fields, and data types before you start the archiving process. Otherwise, queries will fail.
Archive data
Log in to DMS 5.0.
-
In the top navigation bar, choose .
NoteIf you use the DMS console in simple mode, move the pointer over the
icon in the upper-left corner of the DMS console and choose . In the upper-right corner, click Data Archiving.
On the Ticket Application page, configure the following parameters:
Parameter
Required
Description
archiving destination
Yes
Select dedicated storage.
source database
Yes
Search for and select the source database.
archiving configuration
Yes
Select the table to archive.
Optional: Enter the filter conditions for the data to be archived. Example:
gmt_modified<='${6_month_ago}'.NoteIf you need to use a time variable, for example, to archive data from six months ago, first configure the variable in the variable configuration section.
Optional: Click Add to add multiple source tables.
archive table mapping
No
After data is archived to dedicated storage, the archive table mapping section displays information about the archived table, such as its name, columns, and shard key.
variable configuration
No
You can use variables when you configure filter conditions for archiving. For example, you can create a time variable named
6_month_agoin the yyyy-MM-dd format with an offset of -6 months. If the current date is 2021-08-12, the${6_month_ago}variable resolves to 2021-02-12. For more information about how to configure time variables, see Configure time variables.Post-archive actions
No
Whether to delete archived data from the source tables.
Clean up the archived data of the original table (delete-No Lock): DMS automatically deletes the archived data from the source tables by using the
DELETEstatement. Temporary backup tables are created in the source database to store the archived data. Make sure the source database has enough storage space. After verifying that the archived data is correct, create a Normal Data Modify ticket to clear the temporary backup tables.If you do not select the cleanup option, the archived data remains in the source tables. To delete the data manually:
Create a regular data change ticket to delete the archived data. For more information, see Normal Data Modify.
Create a lock-free change ticket to optimize storage usage. For more information, see Perform lock-free DDL operations.
Operation Mode
Yes
Select an operation mode for the archiving task:
Single execution: After the ticket is approved, the archiving task runs only once.
Cyclic scheduling: After the ticket is approved, the archiving task runs on the configured schedule. For more information, see Cyclic scheduling.
Click Submit.
After the ticket is approved, the system automatically runs the data archiving task. Wait for the task to complete.
If the task fails, you can click Details in the Actions column of the execution record to view the task logs and identify the cause of the failure. If the failure is due to an intermittent issue, such as a network or database connection failure, you can click Retry Breakpoint to retry the task.
NoteThe archived data is stored in the Parquet file format, and the data is compressed.
Restore archived data to the source database
Billing
This feature is free, but you are charged for the public outbound traffic it generates from Object Storage Service (OSS).
Limitations
Only one restoration task can run at a time.
This feature is available only for the following source database types: ApsaraDB RDS for MySQL, PolarDB for MySQL, and AnalyticDB for MySQL V3.0.
Procedure
On the Data Archiving Tickets page, set View to Ticket View.
Find the target ticket and click Details in the Actions column.
On the Data Archiving Ticket List page, in the Execution section, click Restore to Source Database in the Actions column.
In the dialog box that appears, click OK.
A restoration task is added and runs automatically. You must wait for its status to change from Executing to Successful. The task duration depends on the amount of data to be restored.
ImportantRestoring archived data to the source database creates temporary tables, which can consume significant storage space. Proceed with caution.
View the restored data.
In the Basic Information section of the ticket details page, click the database name and then click Query in the pop-up window.
Double-click the target table name and click Execute.
You can view the restored data in the results section at the bottom of the SQL Console page.
Delete archived data from dedicated storage
This operation is irreversible. Proceed with caution.
You can physically delete data from dedicated storage that was archived by a one-time or periodic archiving ticket. This action releases the occupied storage space.
Usage notes
After you delete archived data, you can no longer query or restore it.
Procedure
On the Data Archiving Tickets page, set View to Ticket View.
Find the target ticket and click Details in the Actions column.
Go to the Data Archiving Ticket List page. In the Execution section, click More > Delete in the Actions column of the target task.
In the dialog box that appears, click OK.
FAQ
Q: When data from a logical database is archived, are its tables merged into a single physical table?
A: Yes. As a result, you can query data from all the original tables by querying any one of them in the archive view.
Q: If a ticket uses periodic archiving, can I query data that was archived within a specific time frame?
A: Yes. For periodic archiving tasks, each run generates an archive for a specific time frame. You can use the archive's creation time to query data from that period.
Q: How can I query all data from a specific table that has been periodically archived, or all data from that same table archived across different tickets?
A: Go to the logical data warehouse page. On the Data Source tab, choose . Expand the target database and double-click the target table name or ticket number. A query SQL statement is automatically populated in the SQL window. Click Execute to view the archived data in the results section.
Q: When archiving data from an ApsaraDB RDS database to dedicated storage, if I select the option to clean up the source table data, how much space will the temporary backup table occupy in the source database?
A: The temporary backup table can occupy up to the same amount of space as the original data in the source database.