Archive data using DMS
As your business data grows, you need a way to store it for the long term. However, data storage costs can be high. Data Management Service (DMS) andAnalyticDB for PostgreSQL in Serverless mode provide a data archiving feature. This solution offers a flexible, low-cost, and high-performance way to archive and analyze data from your databases.
Features
DMS lets you flexibly archive business data, such as production logs and transaction records.AnalyticDB for PostgreSQL in Serverless mode serves as the data archiving engine and provides the following benefits:
-
Supports key archiving capabilities, including table-level archiving, custom archiving conditions, data mapping, and data cleanup.
-
Supports custom periodic archiving to meet auditing and historical data analysis requirements.
-
When you select the Cost-effective option, the instance automatically starts when an archiving task begins and pauses after it completes. This approach significantly reduces costs by using compute resources only on demand.
-
AnalyticDB for PostgreSQL in Serverless mode delivers powerful data analysis performance. Compared to storage media like Object Storage Service (OSS), it helps you manage archived data in a structured way and run efficient analysis on demand.
-
Supports analyzing archived data directly in AnalyticDB for PostgreSQL.
AnalyticDB for PostgreSQL supports archiving data from the following data sources:
-
RDS MySQL
-
PolarDB for MySQL
-
PolarDB-X
-
AnalyticDB for MySQL 3.0
-
RDS PostgreSQL
-
PolarDB for PostgreSQL
Comparison of data archiving solutions
|
Archiving solution |
Cost-effectiveness |
Management ease |
Query and analysis |
|
Archiving data in an OLTP database |
Poor |
Excellent |
Fair |
|
Archiving data in Object Storage Service (OSS) |
Excellent |
Poor |
Poor |
|
Archiving data in a traditional OLAP engine |
Poor |
Excellent |
Excellent |
|
Archiving data in AnalyticDB for PostgreSQL in Serverless mode |
Excellent |
Excellent |
Excellent |
Prerequisites
-
You have created an AnalyticDB for PostgreSQL instance in Serverless mode as the archive destination. For more information, see Create an instance.
-
You have created an account for the archive destination database. For more information, see Create a database account.
Usage notes
We recommend using an instance in Serverless mode as the destination data archiving engine. This allows you to benefit from ultra-low storage prices and high-performance data analysis. When you create a data archiving ticket, select Cost-effective to automatically start the instance when the task begins and pause it after the task completes.
If you choose to automatically clean up data from the source table during the archiving process, ensure the source table has enough reserved space to prevent errors.
AnalyticDB for PostgreSQL supports instances in both Elastic Storage mode and Serverless mode.
To run a periodic archiving task, the control mode for both the source and destination databases must be Secure Collaboration or Stable Change. If you only need to run the archiving task once, there are no restrictions on the database control mode.
NoteIf the control mode of an instance is Stable Change, we recommend enabling secure access or changing the control mode to Secure Collaboration before running a periodic archiving task. This prevents task failure due to an expired logon. For more information, see Enable secure access and Change the control mode.
Step 1: Access data archiving
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
- Find the instance that you want to manage and click the instance ID.
-
On the Basic Information page, click Log On to Database in the upper-right corner.
-
On the Logon Instance page, enter the Database Account and Database Password.
-
Click Log On.
-
In the top menu bar, choose .
Step 2: Create an archiving ticket
-
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 of the page, click Data Archiving.
On the New Data Archiving Ticket page, configure the parameters.
Parameter
Required
Description
Task Name
Yes
Enter a clear and descriptive name for the task for easy identification.
Archive Destination
Yes
Select AnalyticDB for PostgreSQL.
ADB Instance
Yes
Search for and select the target AnalyticDB for PostgreSQL instance.
NoteIf you select Cost-effective for a pay-as-you-go instance in Serverless mode, you gain the following advantages:
The instance starts automatically when the archiving task begins.
The instance pauses automatically after the archiving task completes.
While the archiving task is running, the instance is in the Running state, and you are charged for compute nodes and storage. For more information, see Billing.
After the archiving task completes, the instance is in the Paused state, and you are charged only for storage.
Database
Yes
Search for and select the source database.
Archiving Configuration
Yes
Select the tables you want to archive data from.
Optional: Enter filter conditions for the data to be archived.
NoteIf you need to use time variables, such as archiving data from six months ago, you must first set up Variable Configuration.
Archive Table Mapping
No
You can click Edit in the Actions column for a table to edit the target table name, column information, sharding key, and partition key.
Variable Configuration
No
Configure time variables. For more information, see Configure time variables.
Post-execution Action
No
If you select Cleanse Archived Data from Source Table (delete-lock-free), the system automatically deletes the archived data from the source table after the task completes. This operation uses a lock-free
DELETEstatement. During this process, a temporary backup table is created in the source database. Ensure you have enough space in the source database to prevent the instance from becoming unavailable.To clean up the temporary backup table, you can create a common data change ticket after confirming the data has been archived correctly.
If you do not select Cleanse Archived Data from Source Table (delete-lock-free), you must manually delete the data from the source table and optimize the table space after the data has been archived.
Cleanse source table data: Create a common data change ticket to clean up the archived data from the database. For more information, see Common data change.
Optimize source table space: Create a lock-free change ticket to optimize the source table space. For more information, see Implement lock-free schema changes by using lock-free change tickets.
Run Mode
Yes
Select a run mode. The following modes are supported:
One-time Execution: The archiving task runs only once after the ticket is approved.
Periodic Scheduling: The archiving task runs periodically according to the configured schedule once the ticket is approved. For more information about the configuration, see Periodic Scheduling.
-
In the Preview Archived Data dialog box that appears, click OK.
Once the ticket is approved, the system automatically runs the data archiving task.
If the task fails, go to the Execution section of the ticket and click Details in the Actions column to view the logs and identify the cause. If the failure was due to a temporary issue, such as a network or database connection error, you can click Resume from Breakpoint to retry the task.
The task completes.
Step 4: Query archived data
- Log on to the AnalyticDB for PostgreSQL console.
- In the upper-left corner of the console, select a region.
-
Find your target instance and click the instance ID.
-
If you selected Cost-effective when configuring the ticket parameters, you must start the instance. On the Basic Information page, choose in the upper-right corner.
-
On the Basic Information page, click Log On to Database in the upper-right corner.
-
On the Logon Instance page, enter the Database Account and Database Password.
-
Click Log On.
-
In the Logged-in Instances list on the left side of the DMS console, find the archive instance and database, and then double-click the database.
-
On the SQL Console tab, run a
SELECTstatement to query the archived data.SELECT * FROM customer;
Periodic scheduling
When Operation Mode is set to Cyclic scheduling, configure the following parameters.
| Parameter | Description |
|---|---|
| Scheduling Cycle | The recurrence frequency: Hour, Day, Week, or Month. If you select Hour, configure the Timed Scheduling parameter. If you select Day, configure the Specific Point in Time parameter. If you select Week or Month, configure the Specified Time and Specific Point in Time parameters. |
| Timed Scheduling | Applies when Scheduling Cycle is Hour. Choose one of two methods: run at a fixed interval (set Starting Time, Intervals in hours, and End Time), or run at specific hours. Example: starting at 00:00, interval of 6 hours, ending at 20:59 — the task runs at 00:00, 06:00, 12:00, and 18:00. |
| Specified Time | Applies when Scheduling Cycle is Week or Month. Select the days of the week or month on which the task runs. |
| Specific Point in Time | The time of day the task runs on the specified days. Example: 02:55. |
| Cron Expression | Auto-generated based on your scheduling settings. |