

# Data movement considerations

In a database cluster group for Aurora, the outcome of a data movement job depends on the configuration of the source and destination member clusters and the data mappings in the collocation. Some objects and configurations block a move. Review these considerations before you run a move.

## What a move includes
<a name="databaseclustergroups-data-movement-what-moves"></a>

What a job moves depends on the scope of the data mappings in the collocation that you move.

A job moves the following:
+ For a table mapping, each table with its columns, comments, secondary indexes, constraints, and `AUTO_INCREMENT` counter.
+ For a database mapping, everything created within the database, including tables, views, stored routines, triggers, and events.

For a database mapping, the `DEFINER` account of each of these objects must already exist on the destination member cluster, or the precheck fails the move.

A job doesn't move the following:
+ Users, roles, and role memberships. The `PRESERVE_GRANTS_FOR` option copies only the direct grants of the users and roles that it names. Each account that you list must exist on both member clusters and have direct grants on the moving objects, or the move fails.
+ Table statistics. They are recomputed on the destination member cluster.
+ Writes that don't reach the source's binary log. The CDC phase reads the binary log, so a write made during the move in a session with `sql_log_bin = 0` doesn't reach the destination member cluster.

## Prechecks
<a name="databaseclustergroups-move-considerations-prechecks"></a>

Before any row moves, the job runs prechecks. A precheck confirms that the objects exist on the source, that no conflicting object exists on the destination member cluster, and that the objects are eligible to be moved. For the reasons that an object might not be eligible, see [Limitations](#databaseclustergroups-move-considerations-limitations). When one precheck fails, the job still runs the other prechecks, so you receive every failure at once.

`EXPLAIN` runs every precheck that the routing layer can run and reports each failure without starting a job. The job runs its prechecks again on the member clusters after it starts, so a move that passes `EXPLAIN` can still fail if something changes in between.

## Limitations
<a name="databaseclustergroups-move-considerations-limitations"></a>

The following limitations apply to a move:
+ A job moves one collocation. You can't move objects from more than one collocation in one operation. To move objects from several collocations, run one move for each collocation.
+ A job moves a whole collocation. You can't move an individual table out of a collocation. To move objects separately, give them their own collocation first.
+ A table that has a foreign key, or that is referenced by a foreign key, can't be moved. The precheck fails the move in this case. You can drop the constraint before the move and re-create it on the destination member cluster afterward, but the table has no foreign key enforcement in between.
+ A trigger on a table in a table mapping is not supported. The precheck fails the move in this case. Triggers are supported for tables within a database mapping.
+ A database cluster group for Aurora runs one data movement job at a time. While a job is active, the routing layer rejects the `MOVE` statement for another move. The next move can start after the active job ends and its `cleanup_status` reads `Complete`.
+ Schema changes (DDL) on the source objects are blocked while a job runs.
+ Changes to the data mappings of the moving collocation are rejected while a job runs.
+ One job can move at most 10,000 tables and 1 TiB of table data. To move more, divide the objects into several collocations, and run one move for each collocation.
+ A move is blocked if binary logging is on and the source's `binlog_format` isn't `ROW`, `binlog_row_image` isn't `FULL`, `binlog_row_value_options` includes `PARTIAL_JSON`, `binlog_error_action` isn't `ABORT_SERVER`, binary log transaction compression is on, a binary log filter drops a database that the move carries, or the source replicates from another server with `log_replica_updates` off. If binary logging is off on the source, the job turns it on for the move. Don't change `binlog_format` at the session level while a job is running.
+ A move is blocked if table names collide under the destination member cluster's `lower_case_table_names` setting.

## Backup and restore
<a name="databaseclustergroups-move-considerations-backup-restore"></a>

Restoring a database cluster group for Aurora doesn't resume a data movement job. If you restore a group while a data movement job is in flight, the job behaves differently in the restored group and in the source group:
+ In the restored group, a job that hasn't reached the cutover is canceled, and Aurora removes the objects that the job created.
+ In the source group, the original job continues to run. The restore doesn't cancel it or change its progress.
+ In the restored group, Aurora also finishes any cleanup that a canceled or completed job didn't finish. This cleanup starts only after both of the following are true:
  + The member clusters that the job moved data between each have an available writer DB instance.
  + The routing layer is created.

To check the state of a job, query `dbclustergroup_data_movement.move_info` at the restored group's routing endpoint.

For more information about backups, see [Backing up and restoring a database cluster group for Aurora](databaseclustergroups-backups.md).