What AWS DMS does and what it does not do
AWS DMS moves rows. A replication instance (or a DMS Serverless replication) connects to a source endpoint and a target endpoint. During the full load it reads every selected table with ordinary queries and writes the rows to the target, several tables at a time. With change data capture (CDC) it reads the changes from the log of the source (the SQL Server transaction log through MS-Replication or MS-CDC, PostgreSQL logical decoding, the MySQL binary log, the Oracle redo log through LogMiner or Binary Reader, MongoDB change streams) and applies them to the target as inserts, updates and deletes. Changes made while a table is being loaded are cached and applied as soon as that table is complete.
It is a data tool. What it leaves to you is at least as important as what it does:
- No schema or code conversion. When DMS creates target tables itself, it creates tables and primary keys (in some cases unique indexes) with its own type mapping, and nothing else: no secondary indexes, foreign keys, defaults, views, stored procedures, functions or triggers. The identity property of SQL Server columns and
AUTO_INCREMENTin MySQL are not carried over either. Converting the schema and the code is a separate step: DMS Schema Conversion (a free part of AWS DMS), the AWS Schema Conversion Tool, Babelfish Compass for Babelfish, or your own scripts. - No logins, users, roles or permissions, no SQL Server Agent jobs, linked servers or Database Mail, no Oracle scheduler jobs. These are recreated on the target by hand or by script.
- No sequence values. Rows arrive with their key values, but sequences and identity counters on the target are not advanced. AWS says so explicitly for PostgreSQL targets: set the sequences after you stop replication.
- Only some DDL during CDC. What is replicated depends on the source: MySQL sources replicate some column changes but not
DROP TABLEorRENAME TABLE, renames withsp_renameare not supported on SQL Server, and DMS does not captureTRUNCATEfrom SQL Server. Freeze schema changes until after the switch. - Cascades from MySQL are not replicated. MySQL writes no binary log events for rows changed by
ON DELETE CASCADEorON UPDATE CASCADE, so DMS cannot apply them to child tables. - No consistent picture during the load. Tables are loaded one by one and in parallel, in no particular order. The target only becomes consistent once all tables are loaded, the cached changes are applied and CDC has caught up. Do not use it for reports before then.
For moves within one engine, AWS DMS also offers homogeneous data migrations, which use the engine's native tools instead of the DMS replication engine; AWS recommends them for MySQL to MySQL, for example. Check which source and target combinations they support for your versions.
When to use AWS DMS, and when a native route is better
AWS DMS is the general-purpose route into AWS, and the only managed CDC route when the engine changes. Within one engine, the native tools of the engine usually copy more (indexes, code, users) and are faster. A rough guide:
| Situation | Usually the better route | Why |
|---|---|---|
| SQL Server to Amazon RDS for SQL Server, a window of an hour or more | Native backup and restore through S3, full and log backups for the catch-up | Copies the whole database including indexes, code and users; DMS only copies tables |
| SQL Server to Babelfish or Aurora PostgreSQL | Schema first (Babelfish Compass or DMS Schema Conversion), then AWS DMS | Different engine: there is no native backup route, and DMS is the managed CDC route |
| Oracle or SQL Server to PostgreSQL or MySQL | Schema conversion, then AWS DMS (full load + CDC) | Same reason; the conversion is the bigger job |
| PostgreSQL to RDS or Aurora PostgreSQL | pg_dump / pg_restore offline; native logical replication or homogeneous data migrations online | Native tools keep the exact types; AWS DMS works but needs the same care with keys and LOBs |
| MySQL or MariaDB to RDS or Aurora | MySQL Shell or mydumper dump and load, then binary log replication into RDS | Faster bulk load and exact types; DMS when you need filtering or a change of engine |
| Version upgrade within RDS or Aurora | Blue/green deployment or an in-place upgrade | No copy outside the service and a managed switchover |
| Oracle to Amazon RDS for Oracle | Data Pump offline; AWS DMS or GoldenGate online | Data Pump copies code and objects; DMS adds CDC |
| MongoDB to Amazon DocumentDB | mongodump / mongorestore offline; AWS DMS in document mode online | DMS is the managed CDC route into DocumentDB |
| Relational data to DynamoDB | AWS DMS with object mapping, or an export and AWS Glue | The data model changes, so the mapping is the real work |
AWS DMS also fits a combined approach: load the target with a native tool (a backup restore, Data Pump or pg_dump), then start a CDC-only task from the log position of that copy. That keeps the fast native bulk load and adds the catch-up.
Be careful with DMS when many large tables have no primary key, when most of the data is in large objects, when the change rate is so high that one task cannot keep up, or when the target must be transactionally consistent at every moment. In those cases an offline route, or a native replication route, is often the safer choice.
Prerequisites per source database for change data capture
A full load only needs read access. Change data capture needs the source to log enough detail and to keep the log long enough for DMS to read it. Several of these settings need a restart, so plan them in a maintenance window well before the migration.
| Source | Log settings | How DMS reads changes | Keys and objects | Retention |
|---|---|---|---|---|
| SQL Server | FULL recovery model (bulk-logged is also accepted) and a full backup taken before the start | MS-Replication (needs a distributor, tables with a primary key) or MS-CDC (also for tables without a primary key); DMS can enable MS-CDC itself with SetUpMsCdcForTables; on Amazon RDS: msdb.dbo.rds_cdc_enable_db | Primary key for reliable updates and for LOB columns; not supported: columnstore indexes, memory-optimized tables, temporal tables, sparse columns, accelerated database recovery | Changes must not leave the active log before DMS has read them; DMS can read log backups (on RDS from engine version 3.5.3) |
| PostgreSQL | wal_level = logical; on RDS and Aurora rds.logical_replication = 1 (static, needs a reboot); enough max_replication_slots and max_wal_senders | A logical replication slot with test_decoding or pglogical; wal_sender_timeout 0 or at least 10 seconds | Primary key: without one, DMS ignores updates and deletes; REPLICA IDENTITY FULL is a workaround (not with pglogical); tables with arrays need a primary key | The slot keeps WAL until DMS has read it, so a stopped task fills the disk; a low max_slot_wal_keep_size makes the task fail |
| MySQL and MariaDB | Binary log on, binlog_format = ROW, binlog_row_image = FULL; on RDS automated backups enabled | Reads the binary log as a replica would (REPLICATION CLIENT and REPLICATION SLAVE); GTIDs are not used | Primary key strongly recommended; generated columns and cascades are not captured; no binary log transaction compression | binlog_expire_logs_seconds of 86400 or more; on RDS mysql.rds_set_configuration('binlog retention hours', 24) |
| Oracle | ARCHIVELOG mode; minimal supplemental logging at database level plus primary key logging (DMS adds it per table unless switched off) | LogMiner (default) or Binary Reader (useLogMinerReader=N;useBfile=Y) for high redo volumes, ASM or several tasks | Tables without a primary key or unique index need ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS; objects with names over 30 bytes are skipped in CDC | Archived logs available long enough; on RDS rdsadmin_util.set_configuration('archivelog retention hours', 24) |
| MongoDB | A replica set (a standalone server must be converted, which needs a restart) | Change streams on the oplog | Document mode for DocumentDB targets; _id as a separate column (ExtractDocID) for CDC with multi-document transactions | An oplog that holds at least 24 hours of changes |
-- SQL Server: recovery model and CDC status of the database
SELECT name, recovery_model_desc, is_cdc_enabled FROM sys.databases WHERE name = 'Sales';
EXEC msdb.dbo.rds_cdc_enable_db 'Sales'; -- Amazon RDS for SQL Server source only
-- PostgreSQL: logical decoding and existing replication slots
SHOW wal_level; -- must return: logical
SELECT slot_name, plugin, active, restart_lsn FROM pg_replication_slots;
-- MySQL / MariaDB: binary log settings
SHOW VARIABLES WHERE Variable_name IN
('log_bin', 'binlog_format', 'binlog_row_image', 'binlog_expire_logs_seconds');
CALL mysql.rds_set_configuration('binlog retention hours', 24); -- Amazon RDS source only
-- Oracle: archive log mode and supplemental logging
SELECT log_mode, supplemental_log_data_min, supplemental_log_data_pk FROM v$database;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY) COLUMNS;
-- MongoDB (mongosh): replica set status and oplog window
-- rs.status()
-- rs.printReplicationInfo()On MySQL and MariaDB, a change of binlog_format only applies to new sessions: restart the application (or the server) afterwards, or sessions that are still open keep writing in the old format. On SQL Server, the transaction log can fill up when the replication Log Reader is not running; watch the log space during the migration. These are also the points the free scan checks in your database: tables without a primary key, large objects and the binary log or recovery settings.
Setting up: replication instance or Serverless, network and endpoints
There are two ways to run DMS. A replication instance is a managed server that you size yourself: an instance class, storage, an engine version and optionally Multi-AZ; tasks run on it. DMS Serverless replaces the instance with a replication configuration with a minimum and maximum number of DMS capacity units (one DCU is 2 GB of memory); DMS provisions and scales the capacity and manages the engine version. Serverless supports the common relational sources and targets, MongoDB and DocumentDB, but not every endpoint type, and it has its own limits: no views, VPC endpoints are needed to reach services such as S3 and Secrets Manager, and a started replication can only be resumed, not restarted from scratch. Choose a replication instance when you need a specific engine version, run many tasks on one machine, or want a fixed hourly cost.
The network is where most first attempts fail:
- Placement: put the replication instance in the VPC of the target, in private subnets. The subnet group must cover at least two Availability Zones.
- On-premises source: connect through AWS Site-to-Site VPN or AWS Direct Connect, route the on-premises network from the VPC, and open the database port (1433, 5432, 3306, 1521, 27017) in the firewall for the private addresses of the replication instance. A source on the public internet works but needs SSL and a strict IP restriction.
- Security groups: the security group of the target database must accept connections from the security group of the replication instance.
- DNS: if the source endpoint uses on-premises host names, the VPC must be able to resolve them, for example with a Route 53 Resolver outbound endpoint.
- SSL:
--ssl-modeisnone,require,verify-caorverify-full; the verify modes need the CA certificate imported into DMS. RDS for PostgreSQL forces SSL by default and Aurora MySQL 8.4 requires TLS, sononefails there. - Credentials: store them in AWS Secrets Manager and give DMS an IAM role to read the secret, instead of passwords in the endpoint definition.
- Test first: run the connection test from the replication instance for both endpoints before you create the task.
# Example: SQL Server on premises -> Aurora PostgreSQL. Replace the IDs, ARNs and names.
# 1. Subnet group and replication instance in the VPC of the target (private subnets)
aws dms create-replication-subnet-group \
--replication-subnet-group-identifier dms-private \
--replication-subnet-group-description "DMS private subnets" \
--subnet-ids subnet-0aaa1111 subnet-0bbb2222
aws dms create-replication-instance \
--replication-instance-identifier dms-sales \
--replication-instance-class dms.r6i.large \
--allocated-storage 100 \
--replication-subnet-group-identifier dms-private \
--vpc-security-group-ids sg-0ccc3333 \
--multi-az \
--no-publicly-accessible
# 2. Endpoints; the credentials stay in AWS Secrets Manager
aws dms create-endpoint \
--endpoint-identifier src-sales-sqlserver \
--endpoint-type source \
--engine-name sqlserver \
--ssl-mode require \
--microsoft-sql-server-settings '{"DatabaseName": "Sales",
"SecretsManagerSecretId": "dms/src-sales",
"SecretsManagerAccessRoleArn": "arn:aws:iam::111122223333:role/dms-secrets"}'
aws dms create-endpoint \
--endpoint-identifier tgt-sales-aurora \
--endpoint-type target \
--engine-name aurora-postgresql \
--ssl-mode require \
--postgre-sql-settings '{"DatabaseName": "sales",
"SecretsManagerSecretId": "dms/tgt-sales",
"SecretsManagerAccessRoleArn": "arn:aws:iam::111122223333:role/dms-secrets",
"AfterConnectScript": "SET session_replication_role = replica"}'
# 3. Test both connections from the replication instance
aws dms test-connection --replication-instance-arn "$RI_ARN" --endpoint-arn "$SRC_ARN"
aws dms test-connection --replication-instance-arn "$RI_ARN" --endpoint-arn "$TGT_ARN"
aws dms describe-connections --filters Name=endpoint-arn,Values="$SRC_ARN","$TGT_ARN"
# 4. The task: full load + change data capture
aws dms create-replication-task \
--replication-task-identifier sales-full-load-cdc \
--source-endpoint-arn "$SRC_ARN" \
--target-endpoint-arn "$TGT_ARN" \
--replication-instance-arn "$RI_ARN" \
--migration-type full-load-and-cdc \
--table-mappings file://mappings.json \
--replication-task-settings file://task-settings.json
aws dms start-replication-task \
--replication-task-arn "$TASK_ARN" \
--start-replication-task-type start-replicationThe example uses the AfterConnectScript of the PostgreSQL target to set session_replication_role = replica, which skips foreign key checks and user triggers for DMS's own sessions (the user needs the privilege to set it). For a MySQL target, the equivalent is the extra connection attribute Initstmt=SET FOREIGN_KEY_CHECKS=0;. The variables $RI_ARN, $SRC_ARN, $TGT_ARN and $TASK_ARN hold the ARNs that the earlier commands return.
Task types, table mappings and task settings
A task combines a source endpoint, a target endpoint, a migration type, table mappings (which tables, and what happens to their names) and task settings (how the load and the CDC behave).
| Migration type | What it does | Use it for |
|---|---|---|
Full load (full-load) | Copies the selected tables once; changes during the copy are not captured | Offline migrations with the application stopped, and first test loads |
Full load + CDC (full-load-and-cdc) | Starts capturing changes, loads the tables, applies the cached changes per table and then keeps replicating | Most minimal-downtime migrations |
CDC only (cdc) | Replicates changes from a start point: a time, or a native log position (LSN, SCN, binary log position) | After a native bulk load, starting from the log position of that copy |
{
"rules": [
{
"rule-type": "selection", "rule-id": "1", "rule-name": "include-dbo",
"object-locator": { "schema-name": "dbo", "table-name": "%" },
"rule-action": "include"
},
{
"rule-type": "selection", "rule-id": "2", "rule-name": "exclude-audit-log",
"object-locator": { "schema-name": "dbo", "table-name": "AuditLog%" },
"rule-action": "exclude"
},
{
"rule-type": "transformation", "rule-id": "3", "rule-name": "rename-schema",
"rule-target": "schema",
"object-locator": { "schema-name": "dbo" },
"rule-action": "rename", "value": "sales"
},
{
"rule-type": "transformation", "rule-id": "4", "rule-name": "lowercase-tables",
"rule-target": "table",
"object-locator": { "schema-name": "%", "table-name": "%" },
"rule-action": "convert-lowercase"
},
{
"rule-type": "transformation", "rule-id": "5", "rule-name": "lowercase-columns",
"rule-target": "column",
"object-locator": { "schema-name": "%", "table-name": "%", "column-name": "%" },
"rule-action": "convert-lowercase"
},
{
"rule-type": "table-settings", "rule-id": "6", "rule-name": "orders-in-parallel",
"object-locator": { "schema-name": "dbo", "table-name": "Orders" },
"parallel-load": {
"type": "ranges",
"columns": ["OrderId"],
"boundaries": [["10000000"], ["20000000"], ["30000000"]]
}
},
{
"rule-type": "table-settings", "rule-id": "7", "rule-name": "documents-full-lob",
"object-locator": { "schema-name": "dbo", "table-name": "Documents" },
"lob-settings": { "mode": "unlimited", "bulk-max-size": "0" }
}
]
}{
"TargetMetadata": {
"SupportLobs": true,
"FullLobMode": false,
"LimitedSizeLobMode": true,
"LobMaxSize": 64,
"BatchApplyEnabled": false
},
"FullLoadSettings": {
"TargetTablePrepMode": "DO_NOTHING",
"MaxFullLoadSubTasks": 8,
"CommitRate": 10000,
"TransactionConsistencyTimeout": 600,
"StopTaskCachedChangesNotApplied": true,
"StopTaskCachedChangesApplied": false
},
"ValidationSettings": {
"EnableValidation": true,
"ThreadCount": 5
},
"Logging": {
"EnableLogging": true
}
}- Selection rules include or exclude schemas and tables, with
%as a wildcard; an exclude rule wins over a broader include. Name MySQL databases explicitly instead of using%, or DMS also selects the system databases. Transformation rules rename schemas, tables and columns, change case, and add or remove columns. Theobject-locatoralways uses the source names. From SQL Server or Oracle to PostgreSQL, convert table and column names to lower case so that they match a schema created without quoted identifiers. - LOB modes: in limited mode (
LimitedSizeLobModewithLobMaxSizein kilobytes, at most 100 MB) LOBs travel inline with the row, which is fast, but anything larger is truncated with only a warning in the task log, so check the largest value per column first. Full mode (FullLobMode,LobChunkSize64 KB recommended) copies every LOB separately, piece by piece, without truncation, and is much slower. Inline mode (InlineLobMaxSize, with full mode) sends small LOBs inline and the rest as in full mode. Atable-settingsrule can set the mode per table, as in the example for theDocumentstable. - Keys and LOBs: during CDC, DMS looks up LOB values in the source by primary key or unique index, so tables with LOB columns need one; full and inline mode need it even for a full load.
- Target table preparation:
DO_NOTHINGleaves existing tables and rows as they are,TRUNCATE_BEFORE_LOADempties them, andDROP_AND_CREATEdrops them and lets DMS create new ones with its own type mapping. UseDO_NOTHINGwith a schema you created and checked yourself: the tables keep your data types, defaults, identity columns, partitioning and collations, and DMS cannot drop anything. The Babelfish endpoint only supports this mode, and AWS advises against drop and create for Babelfish through the Aurora PostgreSQL endpoint as well. The catch: before a rerun, empty the tables yourself, or the rows arrive twice. - Foreign keys and triggers: tables load in parallel and in no particular order, so active foreign keys make the full load fail. Disable them on the target (or skip them for DMS sessions, as in the example), and disable triggers that write audit rows or totals, because those rows are already being replicated from the source and would be written twice. Create primary keys before the load (CDC needs them to apply updates and deletes). With
StopTaskCachedChangesNotAppliedthe task stops after the full load: create the secondary indexes then, before the backlog of changes is applied. Enable foreign keys and triggers at the cutover. - Parallel load:
MaxFullLoadSubTaskssets how many tables load at the same time (default 8, maximum 49). Atable-settingsrule withparallel-loadsplits one large table into ranges or partitions. Each segment takes memory on the replication instance;CommitRate(default 10,000 rows, maximum 50,000) and the LOB size multiply that. - Batch apply:
BatchApplyEnabledapplies CDC changes in batches instead of one transaction at a time, which helps a target that cannot keep up. It needs a primary key or unique key on the source tables, works with LOBs only in limited mode, and does not support target tables that have both a primary key and a unique constraint. - Logging:
EnableLoggingwrites the task log to CloudWatch Logs. Without it, LOB truncation warnings and apply errors are hard to find.
A large migration is often split into several tasks: one for the tables with large LOBs in full mode, one for the rest in limited mode, sometimes one per schema. Each task with CDC reads the source log separately (on PostgreSQL every task has its own replication slot), so do not split into more tasks than the source can serve.
Running the task and following change data capture
After the start, DMS captures changes from that moment and loads the tables. Per table you see the state move from loading to completed; changes made during the load of a table are cached on the replication instance and applied once that table is complete. With StopTaskCachedChangesNotApplied set, the task stops after the full load so you can create secondary indexes; resume it afterwards. From then on the task replicates continuously, and the question is how far the target lags behind.
# Per table: state, rows loaded, changes applied and validation state
aws dms describe-table-statistics --replication-task-arn "$TASK_ARN" \
--query 'TableStatistics[].[SchemaName,TableName,TableState,FullLoadRows,Inserts,Updates,Deletes,ValidationState]' \
--output table
# Task status, full load progress and the reason of the last stop
aws dms describe-replication-tasks --filters Name=replication-task-arn,Values="$TASK_ARN" \
--query 'ReplicationTasks[].[Status,ReplicationTaskStats.FullLoadProgressPercent,StopReason]'
# After the full load stopped (StopTaskCachedChangesNotApplied): create the secondary indexes, then resume
aws dms start-replication-task --replication-task-arn "$TASK_ARN" \
--start-replication-task-type resume-processing- CDCLatencySource: the seconds between the last change read from the source and now. When it is high, reading the source is the bottleneck: log access, LogMiner on a busy Oracle database, the network, or a long-running transaction.
- CDCLatencyTarget: the seconds between the oldest change waiting to be committed on the target and now. When it is high while the source latency is low, applying is the bottleneck: tables without a primary key or index on the target, triggers, a small target or replication instance, LOB lookups, or one-by-one apply where batch apply would help.
- CDCIncomingChanges: the number of change events waiting to be applied. At the cutover it has to reach zero.
- Full load:
FullLoadThroughputRowsTargetand the table statistics show progress per table. Measure the time of the largest tables in a test run; it decides how long the source must keep its log. - Replication instance:
FreeableMemory,SwapUsage,CPUUtilizationandFreeStorageSpace. Swapping usually means the LOB settings, the commit rate or the number of parallel tables are too high for the instance. - Source: the WAL kept by the replication slot (
pg_replication_slots), the transaction log space on SQL Server, and the binary log or archive log retention. Set CloudWatch alarms on the latencies and on free storage on both sides.
Large batch jobs on the source (nightly imports, month-end processing) cause latency peaks that can take hours to absorb. Look at the latency over at least a week before you fix the cutover moment, and plan it outside those jobs. Long-running transactions also delay the start: before the full load, DMS waits for open transactions up to TransactionConsistencyTimeout (600 seconds by default).
Premigration assessment and data validation
Before the first start, run a premigration assessment on the task. It checks the task against the source and target: unsupported data types, tables without a primary key, LOB settings, and for several engines the CDC prerequisites. The results go to an S3 bucket; the run needs an IAM role that can write there.
aws dms start-replication-task-assessment-run \
--replication-task-arn "$TASK_ARN" \
--service-access-role-arn arn:aws:iam::111122223333:role/dms-assessment \
--result-location-bucket my-dms-assessments \
--assessment-run-name sales-premigration- Data validation (
EnableValidation) compares each row on the source and the target after the full load of a table, and then the changed rows during CDC. Per table it reports a state such as Validated, Pending records, Mismatched records or No primary key; failed rows are written toawsdms_control.awsdms_validation_failures_v1on the target, with the key and the differing values. - Validation needs a primary key or unique index on every table and works for relational sources and targets (Oracle, PostgreSQL, MySQL and MariaDB, SQL Server, Db2 LUW, and Redshift or S3 as target). For DocumentDB or DynamoDB targets you check counts and samples yourself.
- It reads every row on both sides, which costs time and load on both databases. A separate validation-only task (
ValidationOnly) controls when that load happens; a full-load validation-only task just before the cutover gives a quick answer to the question whether everything matches. - False mismatches come from differences in precision (fractions of seconds), collation and trailing spaces. Validation rules with
override-validation-functioncan compare such columns in a normalised form; fix real differences in the mapping or the schema instead. - Validation stops when it finds more than 10,000 failed or suspended rows: fix the cause first, then revalidate the tables.
Add your own checks on top: row counts per table, sums of amounts per month, the last order number, open invoices. They are what the business will ask about after the switch.
The cutover, step by step
The cutover is short when everything around it is prepared. Write it down as a script with names and times and rehearse it at least once on a copy.
- Before the day: the latency has been low and stable for days, validation shows Validated for all tables, secondary indexes exist, foreign keys and triggers are ready to enable, logins, jobs and permissions exist on the target, and the connection change is prepared (for example a DNS name with a short TTL).
- 1. Stop writes on the source: stop the application, scheduled jobs and interfaces, or revoke write permissions. Check that no session is still writing.
- 2. Let the last changes arrive: wait until
CDCLatencySource,CDCLatencyTargetandCDCIncomingChangesare zero. A simple extra check: update a row in a small marker table on the source after the stop, and wait until that change is visible on the target. - 3. Validate: look at the validation state of every table, run the row counts and the business checks on both sides.
- 4. Stop the task and set sequences and identity values on the target to the highest value plus a margin (see the code below).
- 5. Enable foreign keys and triggers on the target, and check the foreign keys while doing so (on PostgreSQL
ALTER TABLE ... VALIDATE CONSTRAINT, on SQL ServerWITH CHECK CHECK CONSTRAINT). - 6. Switch the connections of the application, jobs, reports and interfaces, start the application and run the smoke tests.
- 7. Clean up later: remove the replication slot on a PostgreSQL source if it remains, remove the replication publications or MS-CDC on SQL Server (DMS does not remove them), reset the log retention, and delete the replication instance once rollback is no longer needed.
-- PostgreSQL target, after the task has stopped: set every identity or serial sequence
-- to the highest value in its column plus a margin of 1000.
-- The query only generates the statements: review them, then run them.
SELECT format(
'SELECT setval(%L, (SELECT COALESCE(MAX(%I), 0) + 1000 FROM %I.%I), false);',
pg_get_serial_sequence(format('%I.%I', c.table_schema, c.table_name), c.column_name),
c.column_name, c.table_schema, c.table_name)
FROM information_schema.columns AS c
WHERE c.table_schema = 'sales'
AND pg_get_serial_sequence(format('%I.%I', c.table_schema, c.table_name), c.column_name) IS NOT NULL;
-- SQL Server target: DBCC CHECKIDENT ('dbo.Orders', RESEED, <highest value + margin>);
-- MySQL target: ALTER TABLE orders AUTO_INCREMENT = <highest value + margin>;
-- Then stop the task for good
-- aws dms stop-replication-task --replication-task-arn "$TASK_ARN"Rollback. Decide in advance how you go back. The simplest form: the source stays untouched and read-only, and going back means reconnecting the application to it, accepting that writes made on the target after the switch are lost or must be entered again. For a longer way back, prepare a second DMS task in the other direction (CDC only, from the new database to the old one, starting at the switch). That needs the CDC prerequisites on the new database, for example rds.logical_replication on Aurora PostgreSQL, foreign keys and triggers disabled on the old database for DMS, and a rehearsal. Set a deadline after which you fix problems on the new database instead of going back.
Common errors and what to check
Most DMS problems show up as a failed connection test, a task that stops, a table in error or latency that keeps growing. The task log in CloudWatch Logs usually names the cause.
| Symptom | Likely cause | What to check |
|---|---|---|
| Connection test fails or times out | No network path, a security group or firewall blocks the port, DNS cannot resolve the host, wrong SSL mode | Route over VPN or Direct Connect, inbound rules for the replication instance, name resolution from the VPC, --ssl-mode and certificate |
| Task fails at the start of CDC on MySQL or MariaDB | Binary log off or not in ROW format, automated backups off on RDS, missing replication privileges | SHOW VARIABLES LIKE 'binlog%', backup retention on RDS, REPLICATION CLIENT and REPLICATION SLAVE |
| Task cannot resume: log position no longer available | Binary log, archive log or transaction log was removed before DMS read it | Retention against the duration of the full load and of any stop; on SQL Server whether log backups are readable |
| Disk of a PostgreSQL source keeps filling | A replication slot keeps WAL because the task is stopped, slow or deleted | pg_replication_slots (active, restart_lsn); drop slots of tasks that no longer exist |
| Updates and deletes missing for some tables | No primary key: PostgreSQL sources skip updates and deletes; SQL Server without MS-Replication or MS-CDC only captures inserts and deletes | Add a primary key, or REPLICA IDENTITY FULL on PostgreSQL, MS-CDC on SQL Server |
| Long text or binary values cut off on the target | Limited LOB mode with a LobMaxSize below the largest value; only a warning in the log | Maximum length per LOB column; a higher limit, or full or inline mode for those tables |
| LOB columns empty after CDC | Table without primary key or unique index, LOB support off, LogMiner on Oracle 12 with LOB changes | Key on the table, SupportLobs, Binary Reader for Oracle 12 |
| Full load fails on foreign keys or duplicate keys | Foreign keys active on the target, or a rerun into tables that still hold rows (DO_NOTHING) | Disable foreign keys during the load; empty the tables before a rerun |
| Inserts rejected on identity columns of a PostgreSQL target | The column is GENERATED ALWAYS AS IDENTITY, which refuses explicit values | Use GENERATED BY DEFAULT AS IDENTITY during the migration |
| Duplicate key on the first new row after the switch | Sequences or identity values were not set after the stop | setval, DBCC CHECKIDENT or AUTO_INCREMENT per table |
CDCLatencyTarget grows while the source latency is low | Apply on the target is slow: no primary key or index, triggers, a small target or instance, one-by-one apply | Indexes on the target, BatchApplyEnabled, target and instance metrics |
CDCLatencySource grows | Reading the source is slow: LogMiner under a high redo volume, network, long-running transactions | Binary Reader for Oracle, bandwidth, open transactions on the source |
| Task stops with low memory or swaps heavily | LOB size times commit rate times parallel tables is more than the instance can hold; very large transactions | Lower CommitRate, LobMaxSize or MaxFullLoadSubTasks, or a larger (memory-optimized) instance class |
| A table is suspended during CDC | Unsupported DDL on the source, such as a rename or a partition operation | Freeze DDL; reload the table |
| Validation reports mismatches on dates or text | Different precision, collation or trailing spaces | Data types on both sides, validation rules for those columns |
Sizing and costs
Prices differ per region and change over time, so check the AWS DMS pricing page and the AWS Pricing Calculator for your own figures. The structure is stable:
- Replication instance: an hourly price per instance class, about twice as much with Multi-AZ. Some storage is included (according to AWS, 50 GB for T2 and T3 classes and 100 GB for C4, R4 and R5), more is charged separately. T3 instances can also incur CPU credit charges above their baseline.
- DMS Serverless: an hourly price per DCU in use. The maximum DCU you set caps both the capacity and the hourly cost; the minimum determines how fast it can absorb a sudden peak.
- Data transfer: data into DMS is free, and so is transfer between DMS and RDS or EC2 in the same Availability Zone. Transfer across zones or regions is charged at the normal rates. For an on-premises source, the VPN or Direct Connect connection is a cost of its own.
- Free parts: DMS Schema Conversion is free to use (you pay for the S3 storage it uses). Free tier conditions for new accounts have changed in the past; check the current ones.
- Indirect costs: extra log storage on the source for the longer retention, write I/O on the target during the full load (with Aurora Standard, I/O is billed per request), CloudWatch logs, and the target database already running at full size during weeks of CDC.
For sizing, memory matters more than CPU: LOBs, many tables loaded in parallel and large transactions all live in memory on the replication instance, which is why memory-optimized classes (R) are a common choice for large migrations. A pattern that works: a larger class for the full load, a smaller one for the weeks of CDC (changing the class restarts the instance, so do it at a quiet moment), Multi-AZ when CDC runs for a long time, and deleting the instance soon after the switch. Measure the full load of your largest tables in a test run; that figure decides both the duration and the cost.
How the free scan and the full report help
The MigrateMyDatabase scan runs a read-only script on your database that collects the structure, not the data. With an AWS target, it shows whether AWS DMS is a route for your database and lists what makes change data capture harder: tables without a primary key, large objects, and the binary log, WAL or recovery settings. Nothing is uploaded, and the page never connects to your database.
The paid full report contains this runbook filled in for your database: the prerequisites with the commands for your source, the tables that need a key or a separate LOB setting, the target structure to create first, the table mappings and the cutover steps with validation.
Questions
Does AWS DMS migrate stored procedures, indexes and users?
No. AWS DMS migrates data. When it creates tables itself, it creates tables and primary keys, not secondary indexes, foreign keys, views, procedures, functions, triggers, logins or jobs. Convert and create those separately, for example with DMS Schema Conversion or your own scripts, and use the target table preparation mode DO_NOTHING.
How much downtime does a migration with AWS DMS need?
With full load and change data capture, usually minutes: the time to stop writes, let the last changes arrive, validate, set the sequences and switch the connections. The exact time depends on the change rate and on how well the cutover has been rehearsed.
Can AWS DMS migrate tables without a primary key?
A full load works. Change data capture is limited: PostgreSQL sources skip updates and deletes on such tables unless a replica identity is set, SQL Server needs MS-CDC for them, LOB columns need a key during CDC, and data validation needs a primary key or unique index. Add a key before the migration where you can.
Should I use a replication instance or DMS Serverless?
DMS Serverless suits most single migrations: you set a minimum and maximum capacity and DMS scales between them. A replication instance gives you control over the engine version and the instance class, fits many tasks on one machine, and supports some endpoints that Serverless does not.
How long must the source keep its logs?
At least as long as the full load of the largest tables plus any time the task might be stopped, with a margin. AWS suggests 24 hours of binary log or archive log retention as a starting point; for a large full load or a task that may stay stopped over a weekend, keep more and check the disk space.
Why does AWS recommend creating the target tables yourself?
Because DMS creates tables with its own type mapping and without secondary indexes, defaults, identity columns or constraints. A schema you converted and checked yourself, with the preparation mode DO_NOTHING, keeps the right data types and cannot be dropped by the task. For Babelfish targets it is required.
Read next
- Which migration tool for which database move
Every migration route per source database and target platform – AWS, Azure, Google Cloud or your own server – sorted by the downtime it needs. - Database migration routes and downtime: offline, minimal or near-zero
Offline, minimal or near-zero downtime: how to choose a database migration route, what it costs, what breaks online, and the routes per engine. - Stored procedures, functions and triggers: how to rewrite them for another database
What stored procedures, functions and triggers are, and how to rewrite T-SQL, PL/SQL or MySQL code for another engine: method, tools, mapping and examples.
See what makes change data capture harder in your database, such as tables without a primary key, large objects and log settings: run the free read-only scan. Nothing leaves your browser.
Start the free scan