

# Moving a data group to another DB cluster

A move hands a data group from the source DB cluster to the target DB cluster. It runs in two steps, prepare and then execute, and you start each step. Until you execute, you can cancel. For how a move works, see [How a data group move works](#dg-how-moves-work).

You perform the following tasks to move a data group:

1. Check that both DB clusters are ready. For more information, see [Before you move a data group](#dg-move-before).

1. Prepare the move. For more information, see [Preparing a data group move](#dg-move-prepare).

1. Wait until the data group is `ready-to-move`. For more information, see [Monitoring a data group move](#dg-move-track).

1. Execute the move, then point your application at the target DB cluster. For more information, see [Executing a data group move](#dg-move-execute).

You run every move step with the `move-data-group` AWS CLI command and its `--move-operation` parameter.

**Topics**
+ [How a data group move works](#dg-how-moves-work)
+ [Before you move a data group](#dg-move-before)
+ [Preparing a data group move](#dg-move-prepare)
+ [Monitoring a data group move](#dg-move-track)
+ [Executing a data group move](#dg-move-execute)
+ [Canceling a data group move](#dg-move-cancel)
+ [How a move affects your application](#dg-move-impact)
+ [What moves and what stays on the source DB cluster](#dg-move-what-moves)
+ [After you move a data group](#dg-move-after)
+ [What happens when a move fails](#dg-move-failures)

## How a data group move works
<a name="dg-how-moves-work"></a>

You move a data group in two steps, and you decide when each one runs.

1. *Prepare* – The target DB cluster checks that it can take the data group. It imports what the data group needs, such as roles. The source DB cluster locks schema changes (DDL) on the data group. Applications keep reading and writing. The status goes from `active` to `preparing-for-move`, then to `ready-to-move`.

1. *Execute* – The source DB cluster stops writes to the data group and hands its storage to the target DB cluster. Execute also ends open sessions in the data group's databases, so reads of those databases stop too. The status is `move-in-progress`, then `active` on the target DB cluster.

Until the execute step starts, you can cancel the move. The data group then returns to `active` on the source DB cluster. To undo a finished move, move the data group back with a new prepare and execute.

Writes stop only for a short time during the execute step, but the full move operation takes longer. To find out when the move is complete, monitor the data group status until it's `active` on the target DB cluster. Prepare takes longer when the data group holds more objects, such as tables and indexes.

After a move, the source DB cluster endpoints no longer reach the data group. If your applications connect through DB cluster endpoints, point those applications at the target DB cluster endpoints after the move. To keep the same endpoint after a move, connect through data group endpoints instead. For more information, see [Data group endpoints](aurora-data-groups-endpoints.md).

Each data group is its own part of the DB cluster storage volume. A move hands that part of storage from one DB cluster to the other. The data stays where it is, and only its owner changes. As a result, the time to run a move doesn't depend on how much data the data group holds.

For example, suppose that a SaaS application keeps each customer in its own data group on `orders-cluster-1`. One customer, `tenant42`, grows and starts to slow down the others. You prepare a move of `tenant42` to `orders-cluster-2`, which has spare capacity. Your application keeps reading and writing to `tenant42` while the move is prepared. When you execute the move, sessions in `tenant42`'s databases end and writes stop for a short time. When the data group is `active` on `orders-cluster-2`, you point that customer's connections to the `orders-cluster-2` endpoints. The other customers' databases on `orders-cluster-1` stay available the whole time.

## Before you move a data group
<a name="dg-move-before"></a>

A move is refused unless the following are true. Check them before you prepare.

The data group must meet the following conditions:
+ The data group is `active` and has no other control operation running.
+ No data group with the same name is on the target DB cluster, and no database with the same name as one in the data group.
+ Every role that owns objects in the data group or has privileges on them is mapped. `EXPECT_NAME_MATCH` roles exist on the target DB cluster. For more information, see [Managing roles for data groups](aurora-data-groups-users.md).
+ Each `EXPECT_NAME_MATCH` role on the target DB cluster has at least the source role's attributes, a connection limit at least as high as the source role's (no limit, `-1`, counts as highest), and at least the roles granted to the source role. Prepare checks this. It doesn't change the role on the target DB cluster.
+ Any table synchronization for a subscription in the data group has finished. Each table of the subscription is in the ready state (`r`) or hasn't started its synchronization yet (`i`).

The source and target DB clusters must meet the following conditions:
+ The source and target are different DB clusters in the same AWS account and AWS Region.
+ The target DB cluster meets the requirements for data groups, including Aurora I/O-Optimized storage. For more information, see [Requirements for Aurora data groups](aurora-data-groups-reqs-limits.md#dg-requirements).
+ Both DB clusters are `available` and have a writer DB instance.
+ Both DB clusters have the same data group domain. At preview, there is one data group domain, so every DB cluster that supports data groups has the same data group domain. For more information about data group domains, see [Data group domains](aurora-data-groups-overview.md#dg-domains).
+ Both DB clusters run compatible engine versions.
+ Some parameters have the same value on both DB clusters:
  + `shared_preload_libraries`.

  Every DB instance must also be using the current version of its parameter group. If a parameter change is pending a reboot, reboot the DB instance first.
+ The target DB cluster volume stays under 256 TiB after the move.

Aurora also refuses a move in the following cases:
+ A database in the data group owns a logical replication slot. A publication without a slot doesn't block a move. The publication moves with its database.
+ The target DB cluster doesn't have enough replication slots or background workers for the data group's subscriptions.
+ An extension is at a different version on the two DB clusters.
+ A data group migration into the data group is still running.

If a prepared transaction (`PREPARE TRANSACTION`) is open in the data group, prepare doesn't fail. It waits, and the data group stays `preparing-for-move` with no data group event until `COMMIT PREPARED` or `ROLLBACK PREPARED` ends that transaction. The reason appears only as a warning in the PostgreSQL log. Commit or roll back prepared transactions before you prepare a move. If prepare is already waiting, end the transaction or cancel the move with `cancel-move`.

The following queries check the most common causes of a refused or waiting prepare. Run them on the writer DB instance of the source DB cluster as the cluster admin user. Replace {{tenant42}} with the name of your data group. When nothing blocks the move, both queries return no rows.

```SQL
SELECT s.slot_name, s.database
  FROM pg_replication_slots s
  JOIN pg_database d ON d.datname = s.database
  JOIN pg_tablespace t ON t.oid = d.dattablespace
 WHERE t.spcname = '{{tenant42}}';
```

The output resembles the following example.

```
 slot_name | database
-----------+----------
(0 rows)
```

```SQL
SELECT p.gid, p.database, p.prepared
  FROM pg_prepared_xacts p
  JOIN pg_database d ON d.datname = p.database
  JOIN pg_tablespace t ON t.oid = d.dattablespace
 WHERE t.spcname = '{{tenant42}}';
```

The output resembles the following:

```
 gid | database | prepared
-----+----------+----------
(0 rows)
```

The first query lists replication slots owned by the data group's databases. Drop them before you prepare. The second lists open prepared transactions. Commit or roll them back.

Run the following on the writer DB instance of both DB clusters and compare the output. The value must be the same on both.

```SQL
SHOW shared_preload_libraries;
```

The output resembles the following example.

```
                                   shared_preload_libraries
-----------------------------------------------------------------------------------------------
 rdsutils,rds_casts,pg_stat_statements,writeforward,aws_s3_native,pg_columnmask,rds_blue_green,datagroup_utils
(1 row)
```

In each database of the data group on the source DB cluster, list the extensions and their versions.

```SQL
SELECT extname, extversion FROM pg_extension ORDER BY 1;
```

The output resembles the following example.

```
 extname | extversion
---------+------------
 pg_trgm | 1.6
 plpgsql | 1.0
(2 rows)
```

Then, on the target DB cluster, check that the same versions are available. Replace {{pg\_trgm}} with each extension that the first query returned.

```SQL
SELECT name, default_version, installed_version
  FROM pg_available_extensions
 WHERE name = '{{pg_trgm}}';
```

The output resembles the following example.

```
  name   | default_version | installed_version
---------+-----------------+-------------------
 pg_trgm | 1.6             |
(1 row)
```

To check the headroom on the target DB cluster, compare its current volume size with the size of the data group. Read the target volume size from the `VolumeBytesUsed` CloudWatch metric.

```
aws cloudwatch get-metric-statistics \
    --namespace AWS/RDS \
    --metric-name VolumeBytesUsed \
    --dimensions Name=DBClusterIdentifier,Value={{orders-cluster-2}} \
    --start-time {{2026-11-24T00:00:00Z}} \
    --end-time {{2026-11-24T01:00:00Z}} \
    --period 3600 \
    --statistics Maximum
```

Then read the size of the data group on the source DB cluster writer DB instance.

Run the following SQL query in each database of the data group, and add up the results. At preview, `pg_database_size` and `pg_tablespace_size` don't count the data of a database in a data group, so use this query instead.

```SQL
SELECT current_database() AS database,
       pg_size_pretty(sum(pg_total_relation_size(c.oid))) AS size
  FROM pg_class c
 WHERE c.relkind IN ('r', 'm')
   AND NOT c.relisshared;
```

The output resembles the following example.

```
 database |  size
----------+--------
 orders   | 985 MB
(1 row)
```

Prepare the move only if the total stays under 256 TiB, with room left for growth on the target DB cluster.

## Preparing a data group move
<a name="dg-move-prepare"></a>

You can use the AWS Management Console or AWS CLI to prepare a data group move. Prepare checks the target DB cluster and sets up what the data group needs there: it creates the data group's databases, its `DATAGROUP_CONSTRAINED` roles, and its role mappings on the target DB cluster. From the start of prepare, Aurora refuses schema changes (DDL) in the data group. Reads and writes are allowed.

### Console
<a name="dg-move-prepare.CON"></a>

Use the following procedure.

**To prepare a data group move using the console**

1. Sign in to the AWS Management Console and open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. In the navigation pane, choose **Data Groups**.

1. Under **All data groups**, select the data group that you want to move.

1. Choose **Prepare to move**.

   The **Prepare to move** page displays. It shows the **Source data group** and **Source cluster**.

1. Under **Target cluster**, select the DB cluster to move the data group to.

1. Choose **Prepare**.

The data group appears under **Ready to move** with the status **Preparing for move**.

### CLI
<a name="dg-move-prepare.CLI"></a>

Use the `move-data-group` AWS CLI command with the following parameters:
+ `--data-group-identifier` – The identifier or ARN of the data group.
+ `--move-operation` – `prepare-move`.
+ `--target-db-cluster-identifier` – The name of the target DB cluster.

The following example prepares a move of `tenant42` to `orders-cluster-2`.

```
aws rds move-data-group \
    --data-group-identifier {{dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111}} \
    --move-operation prepare-move \
    --target-db-cluster-identifier {{orders-cluster-2}}
```

The output resembles the following example.

```
{
    "DBClusterIdentifier": "orders-cluster-1",
    "TargetDBClusterIdentifier": "orders-cluster-2",
    "DataGroupName": "tenant42",
    "DataGroupIdentifier": "dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "DataGroupArn": "arn:aws:rds:us-east-1:111122223333:data-group:dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "KMSKeyId": "arn:aws:kms:us-east-1:111122223333:key/1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111",
    "StorageEncryptionType": "sse-kms",
    "Status": "preparing-for-move",
    "CreateTime": "2026-11-24T18:02:11.512Z"
}
```

For more information, see [move-data-group](https://docs.aws.amazon.com/cli/latest/reference/rds/move-data-group.html).

If the data group uses the DB cluster key, the move switches it to the target DB cluster key. A data group with its own key keeps it. For more information, see [What happens to the key during a move](aurora-data-groups-encrypting.md#dg-encrypt-move).

## Monitoring a data group move
<a name="dg-move-track"></a>

To monitor a move, check the data group's status. Use the **Ready to move** table in the console, or `describe-data-groups` in the AWS CLI.

```
aws rds describe-data-groups \
    --data-group-identifier dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --query "DataGroups[0].[Status,DBClusterIdentifier,TargetDBClusterIdentifier]" \
    --output text
```

The output resembles the following example.

```
ready-to-move    orders-cluster-1    orders-cluster-2
```

A move goes through these statuses:

1. `active` – Before the move.

1. `preparing-for-move` – Prepare is running.

1. `ready-to-move` – Prepare is done. The data group waits for you to execute or cancel.

1. `move-in-progress` – Execute is running.

1. `active` – The data group is on the target DB cluster. `DBClusterIdentifier` now shows the target DB cluster.

If prepare fails, the data group returns to `active` on the source DB cluster. Aurora also sends events when prepare starts, when the data group is ready to move, and when the move completes, fails, or is canceled. Check the events to tell a failed prepare from a finished one. For more information, see [Viewing data group events](aurora-data-groups-monitoring.md#dg-monitor-events).

## Executing a data group move
<a name="dg-move-execute"></a>

You can use the AWS Management Console or AWS CLI to execute a data group move that's `ready-to-move`. Execute to the same target DB cluster that you prepared for.

During execute, writes to the data group are refused. Execute also ends every open session in the data group's databases, with the error `FATAL: terminating connection due to administrator command` (SQLSTATE `57P01`), so reads of those databases stop too. Other databases on the source DB cluster stay available. When the data group is `active` on the target DB cluster, its databases are only on the target DB cluster.

### Console
<a name="dg-move-execute.CON"></a>

Use the following procedure.

**To execute a data group move using the console**

1. Sign in to the AWS Management Console and open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. In the navigation pane, choose **Data Groups**.

1. Under **Ready to move**, select the data group. Its status must be **Ready to move**.

1. Choose **Execute move**.

### CLI
<a name="dg-move-execute.CLI"></a>

Use the `move-data-group` AWS CLI command with the following parameters:
+ `--data-group-identifier` – The identifier or ARN of the data group.
+ `--move-operation` – `execute-move`.
+ `--target-db-cluster-identifier` – The target DB cluster that you prepared the move for. A different DB cluster is refused.

The following example executes the move of `tenant42`.

```
aws rds move-data-group \
    --data-group-identifier dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --move-operation execute-move \
    --target-db-cluster-identifier orders-cluster-2
```

The output resembles the following example.

```
{
    "DBClusterIdentifier": "orders-cluster-1",
    "TargetDBClusterIdentifier": "orders-cluster-2",
    "DataGroupName": "tenant42",
    "DataGroupIdentifier": "dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "DataGroupArn": "arn:aws:rds:us-east-1:111122223333:data-group:dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "KMSKeyId": "arn:aws:kms:us-east-1:111122223333:key/1a2b3c4d-5e6f-7a8b-9c0d-EXAMPLE11111",
    "StorageEncryptionType": "sse-kms",
    "Status": "move-in-progress",
    "CreateTime": "2026-11-24T18:02:11.512Z"
}
```

Execute doesn't wait for open transactions to finish. It ends them, and they roll back. Finish or stop long transactions in the data group's databases before you execute, and have your application retry transactions that fail with SQLSTATE `57P01`.

Also end sessions that hold temporary tables in the data group's databases before you execute. At preview, a session might still hold a temporary table when the move executes. In that case, the move carries the table's catalog entry to the target DB cluster without its data. In that database on the target, `VACUUM` and `ANALYZE` fail with `heap freeze in progress post datagroup movement`. A later prepare-move of the data group also stalls.

To fix this, connect to that database on the target writer DB instance, find the leftover temporary table, and drop it. Within about a minute, `VACUUM` works again.

```SQL
SELECT n.nspname, c.relname
  FROM pg_class c
  JOIN pg_namespace n ON n.oid = c.relnamespace
 WHERE c.relpersistence = 't';
```

The output resembles the following example.

```
   nspname   | relname
-------------+----------
 pg_temp_235 | tmp_hold
(1 row)
```

Then drop the table. Replace {{pg\_temp\_235}} and {{tmp\_hold}} with the schema and table names that the query returned.

```SQL
DROP TABLE {{pg_temp_235}}.{{tmp_hold}};
```

When the status is `active` and `DBClusterIdentifier` shows the target DB cluster, connect your application to the target DB cluster endpoints. Role and privilege setup on the target can still be finishing for a short time after the status shows `active`, so new connections can fail for up to about 30 seconds. Retry failed connections. For more information, see [How a move affects your application](#dg-move-impact).

## Canceling a data group move
<a name="dg-move-cancel"></a>

You can use the AWS Management Console or AWS CLI to cancel a move that's `preparing-for-move` or `ready-to-move`. You can't cancel a move after it reaches `move-in-progress`.

The status becomes `cancelling-move`, then `active` on the source DB cluster. The data is unchanged, and schema changes are allowed again. The `cancelling-move` status can be brief, so check for `active`.

A cancel removes what prepare created on the target DB cluster: the data group's databases, its role mappings, and the `DATAGROUP_CONSTRAINED` roles. Roles that already existed on the target DB cluster aren't dropped. You can then move the same data group to that DB cluster again.

### Console
<a name="dg-move-cancel.CON"></a>

Use the following procedure.

**To cancel a data group move using the console**

1. Sign in to the AWS Management Console and open the Amazon RDS console at [https://console.aws.amazon.com/rds/](https://console.aws.amazon.com/rds/).

1. In the navigation pane, choose **Data Groups**.

1. Under **Ready to move**, select the data group.

1. Choose **Cancel prepare**.

   The **Cancel prepare of tenant42** dialog box displays.

1. Enter **cancel** in the box, then choose **Cancel prepare**.

### CLI
<a name="dg-move-cancel.CLI"></a>

Use the `move-data-group` AWS CLI command with the following parameters:
+ `--data-group-identifier` – The identifier or ARN of the data group.
+ `--move-operation` – `cancel-move`.

The following example cancels the move of `tenant42`.

```
aws rds move-data-group \
    --data-group-identifier dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111 \
    --move-operation cancel-move
```

The output resembles the following example.

```
{
    "DBClusterIdentifier": "orders-cluster-1",
    "TargetDBClusterIdentifier": "orders-cluster-2",
    "DataGroupName": "tenant42",
    "DataGroupIdentifier": "dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "DataGroupArn": "arn:aws:rds:us-east-1:111122223333:data-group:dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111",
    "Status": "cancelling-move",
    "CreateTime": "2026-11-24T18:02:11.512Z"
}
```

### When you can cancel a move
<a name="dg-move-cancel-table"></a>

The following table shows what a cancel request does in each status.


**Cancel requests by data group status**  

| Status | Result of a cancel request | 
| --- | --- | 
| `preparing-for-move` | Accepted. The data group returns to `active` on the source DB cluster. Prepare might reach `ready-to-move` first, but the cancel still completes. | 
| `ready-to-move` | Accepted. The data group returns to `active` on the source DB cluster, and schema changes are allowed again. | 
| `move-in-progress` | Refused with `InvalidDataGroupStateFault`. Wait for the move to finish, then move the data group back if you need to. | 
| `active` | Refused with `InvalidDataGroupStateFault`, because no move is pending. To undo a finished move, prepare and execute a move back to the original DB cluster. | 
| `cancelling-move` | Refused with `InvalidDataGroupStateFault`. A cancel is already running. | 
| Any other status | Refused with `InvalidDataGroupStateFault`. | 

## How a move affects your application
<a name="dg-move-impact"></a>

The following table shows what your application can do with the data group during each step.


**Application access by status**  

| Status | Reads | Writes (DML) | Schema changes (DDL) | 
| --- | --- | --- | --- | 
| `active`, before the move | Yes | Yes | Yes | 
| `preparing-for-move`, `ready-to-move` | Yes | Yes | No | 
| `move-in-progress` | No. Aurora ends open sessions in the data group's databases. | No | No | 
| `active`, after the move | Yes, on the target DB cluster only | Yes, on the target DB cluster only | Yes, on the target DB cluster only | 

While a move is being prepared, you also can't create or change logical replication subscriptions in the data group, create new databases in it, or rename its databases.

From the start of prepare until the move finishes or you cancel it, you can't change the data group's role mappings or the roles that are mapped to it, and the cluster admin user can't create roles on the source or target DB cluster. Make role changes before you prepare the move. For more information, see [What happens to roles during a move](aurora-data-groups-users.md#dg-users-move). Also don't drop the `EXPECT_NAME_MATCH` roles on the target DB cluster until the move ends. If one is dropped, execute can still succeed, but the moved databases then refuse connections.

From prepare until the move ends, subscriptions in the data group don't start table synchronization. A table that is waiting for its initial copy stays in the `i` state and synchronizes on the target DB cluster after the move. Prepare fails if a table synchronization is already running, so check before you prepare. The following query returns tables that are still synchronizing. Run it in each database of the data group, and wait until it returns no rows.

```SQL
SELECT s.subname AS subscription, r.srrelid::regclass AS table_name, r.srsubstate
  FROM pg_subscription_rel r
  JOIN pg_subscription s ON s.oid = r.srsubid
 WHERE r.srsubstate NOT IN ('r', 'i');
```

The status and the engine don't change at exactly the same moment. Writes can stop shortly after the status shows `move-in-progress`. Writes can resume on the target DB cluster shortly before the status shows `active`.

Plan connection routing before the first move. Data group endpoints follow the data group, so the application keeps the same host name. For more information, see [Data group endpoints](aurora-data-groups-endpoints.md). Connections through DB cluster endpoints don't follow the data group, so keep a record of which DB cluster holds each data group. Update it, or your proxy, when the data group is `active` on the target DB cluster.

## What moves and what stays on the source DB cluster
<a name="dg-move-what-moves"></a>

The following moves with the data group:
+ Every database in the data group, with its tables, indexes, sequences, views, functions, triggers, and large objects.
+ The data group's name, identifier, ARN, tags, and KMS key.
+ Logical replication subscriptions in its databases.
+ Logical replication publications in its databases. After the move, run `SELECT pubname, pubowner::regrole FROM pg_publication;` in each moved database on the target DB cluster. If the owner shows as a number instead of a role name, set it with `ALTER PUBLICATION {{name}} OWNER TO {{role}}`.
+ The privileges and ownership of mapped roles on its objects, and its `DATAGROUP_CONSTRAINED` roles. At preview, column-level privileges aren't moved. Before a move, record the column-level grants on tables in the data group. After the move, revoke all column-level privileges on the moved tables, then grant the ones you recorded again.

  The following query returns a `GRANT` statement for each column-level privilege in the current database. Run it in each database of the data group before the move, save the output, and run the saved statements on the target DB cluster after the move.

  ```SQL
  SELECT format('GRANT %s (%I) ON %I.%I TO %s;',
         x.privilege_type, a.attname, n.nspname, c.relname,
         CASE WHEN x.grantee = 0 THEN 'PUBLIC' ELSE quote_ident(pg_get_userbyid(x.grantee)) END)
    FROM pg_attribute a
    JOIN pg_class c ON c.oid = a.attrelid
    JOIN pg_namespace n ON n.oid = c.relnamespace
    CROSS JOIN LATERAL aclexplode(a.attacl) x
   WHERE a.attacl IS NOT NULL
     AND NOT a.attisdropped
     AND n.nspname NOT IN ('pg_catalog', 'information_schema');
  ```

  The output resembles the following example.

  ```
                              format
  ---------------------------------------------------------------
   GRANT UPDATE (credit_limit) ON public.customers TO reporting;
   GRANT SELECT (id) ON public.customers TO reporting;
   GRANT SELECT (name) ON public.customers TO reporting;
  (3 rows)
  ```

  The move doesn't copy `WITH GRANT OPTION` or `WITH ADMIN OPTION` to the target DB cluster. If a role needs to pass a privilege or role on to other roles, grant it the option again after the move.
+ Optimizer statistics.
+ Setting overrides made with `ALTER DATABASE ... SET` and `ALTER ROLE ... IN DATABASE ... SET` for `DATAGROUP_CONSTRAINED` roles, and comments on databases. At preview, a database's connection limit isn't kept. The database has no connection limit on the target DB cluster. After the move, set it again with `ALTER DATABASE {{name}} CONNECTION LIMIT {{n}}`.

The following stays on the source DB cluster:
+ Databases in the default data group or in other data groups.
+ The DB cluster itself, with its DB instances, endpoints, parameter groups, and settings.
+ Logical replication slots.

Some settings are stored for the whole DB cluster. They don't move. Check them after a move, and set them again on the target DB cluster if you need them:
+ Setting overrides made with `ALTER ROLE ... IN DATABASE ... SET` for `EXPECT_NAME_MATCH` roles.
+ Comments on roles.
+ Collation, character type, and encoding. A moved database takes the settings of the target DB cluster.
+ The owner of large objects.
+ The `pg_cron` run history and commit timestamps.

Moved rows keep the transaction IDs that they had on the source DB cluster. The target DB cluster has its own transaction counter, which can be lower, so new rows on the target can get lower transaction IDs than moved rows.

Don't compare transaction IDs or snapshots taken on the source DB cluster with values on the target DB cluster. The following give wrong answers after a move, with no error:
+ Checking a transaction ID saved on the source with `pg_xact_status`. It can fail with `transaction ID ... is in the future`, or later report `aborted` for a transaction that committed.
+ Finding new rows by comparing `xmin` with the highest value seen before the move. Rows written on the target can have lower values, so they're missed.
+ Checking a target transaction against a snapshot saved on the source with `pg_visible_in_snapshot`.

If your application saves `xmin`, `pg_current_xact_id()`, or `pg_current_snapshot()` values, reset what it saved after each move, for example by starting a sync process again from a full read.

After a move, `VACUUM` and autovacuum don't run on the moved databases until Aurora finishes processing them on the target DB cluster. This can take many hours, even for small databases. To check, run `VACUUM` on a small table in a moved database. Until processing finishes, it fails with `heap freeze in progress post datagroup movement`.

Until `VACUUM` works on a moved database, don't use that database as the template in `CREATE DATABASE ... TEMPLATE`.

## After you move a data group
<a name="dg-move-after"></a>

When the data group is `active` on the target DB cluster, do the following. Each item links to the details.

1. Check that `DBClusterIdentifier` in the `describe-data-groups` output shows the target DB cluster. For more information, see [Monitoring a data group move](#dg-move-track).

1. Point the applications that use the data group at the target DB cluster endpoints, and update your record of where the data group is. Retry connections that fail in the first seconds after the move. For more information, see [Executing a data group move](#dg-move-execute).

1. Revoke all column-level privileges on the moved tables, then run the column-level `GRANT` statements that you saved before the move.

1. Grant `WITH GRANT OPTION` and `WITH ADMIN OPTION` again where roles need them.

1. Set each database's connection limit again with `ALTER DATABASE {{name}} CONNECTION LIMIT {{n}}`.

1. Check the owner of each publication, and set it again if it shows as a number.

1. Set again the settings that are stored for the whole DB cluster, such as `ALTER ROLE ... IN DATABASE ... SET` for `EXPECT_NAME_MATCH` roles, comments on roles, and the owner of large objects.

1. Reset any transaction IDs or snapshots that your application saved before the move.

1. Wait until `VACUUM` works on the moved databases before you use one as a `CREATE DATABASE ... TEMPLATE`.

For details on items 3–9, see [What moves and what stays on the source DB cluster](#dg-move-what-moves).

To move the data group back, prepare and execute a move with the original DB cluster as the target. Follow the same steps as any data group move, starting from [Before you move a data group](#dg-move-before). The following example moves `tenant42` back to `orders-cluster-1`.

```
aws rds move-data-group \
    --data-group-identifier {{dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111}} \
    --move-operation prepare-move \
    --target-db-cluster-identifier {{orders-cluster-1}}

aws rds move-data-group \
    --data-group-identifier {{dg-a1b2c3d4-5678-90ab-cdef-EXAMPLE11111}} \
    --move-operation execute-move \
    --target-db-cluster-identifier {{orders-cluster-1}}
```

Wait until the status is `ready-to-move` before you run the second command.

## What happens when a move fails
<a name="dg-move-failures"></a>

How a failure looks depends on the step:
+ A request that breaks a rule, such as a target without Aurora I/O-Optimized storage, is refused right away with an error. Nothing changes.
+ If prepare fails after it starts, Aurora rolls back its changes. The data group returns to `active` on the source DB cluster. The status alone looks the same as after a cancel, so check the data group events for the reason.
+ If execute fails, Aurora sends a move failed event (RDS-EVENT-0534). Check the data group status and events before you act.

After a timeout or a server error from `move-data-group`, run `describe-data-groups` before you retry. The first request might have worked.

For the errors that move requests return, see [Data group errors](aurora-data-groups-reference.md#dg-ref-errors). For the events, see [Data group events](aurora-data-groups-reference.md#dg-ref-events).