Copy a DynamoDB Table to Another Account/Region
DynamoDB has no "copy table" command, in the AWS CLI or the console. Every copy has two halves: get the data out of the source, and load it into a destination table. AWS gives you four ways to do both, and they differ in what they carry over.
How do I copy a DynamoDB table to another account or region?
There's no native copy-table command. Pick the AWS path that fits: a Scan + BatchWriteItem script for small one-off copies or an existing target, an S3 export-then-import for large tables (optionally filtered to a subset), AWS Backup copy + restore when you want indexes and capacity settings restored with the data, or global tables for ongoing live replication. Each restore or import creates a new table.
| Situation | Best approach |
|---|---|
| Small table, one-off, or an existing target | Scan + BatchWriteItem script |
| Large table, can tolerate a snapshot | S3 export → import (creates new table) |
| Cross-account / cross-region with restore | AWS Backup copy + restore |
| Ongoing live replication (not a one-time copy) | Global tables |
No approach is universally "right": it depends on table size, whether you need a point-in-time snapshot or live data, and whether the destination is a new or existing table. If you'd rather not write the read half, DynoTable can export the source data for you (below).
Approach 1: Scan + BatchWriteItem (the script)
Lowest-tech path: read every item from the source with Scan, write it to the
destination with BatchWriteItem. Works cross-account and cross-region as long as your
script holds credentials for both sides (or assumes a role in the target account),
and it's the only path that writes into an existing table. Create the target
first with the same key schema.
import {DynamoDBClient, ScanCommand, BatchWriteItemCommand} from '@aws-sdk/client-dynamodb';
const src = new DynamoDBClient({region: 'us-east-1'});
const dst = new DynamoDBClient({region: 'eu-west-1'}); // target account's credentials
const SOURCE = 'SourceTable';
const TARGET = 'TargetTable';
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function writeChunk(items) {
let requests = items.map((Item) => ({PutRequest: {Item}}));
for (let attempt = 0; requests.length > 0; attempt++) {
if (attempt === 8) throw new Error(`${requests.length} items still unprocessed`);
if (attempt > 0) await sleep(Math.min(100 * 2 ** attempt, 5000));
const out = await dst.send(new BatchWriteItemCommand({RequestItems: {[TARGET]: requests}}));
requests = out.UnprocessedItems?.[TARGET] ?? [];
}
}
let ExclusiveStartKey;
let copied = 0;
do {
const page = await src.send(new ScanCommand({TableName: SOURCE, ExclusiveStartKey}));
const items = page.Items ?? [];
for (let i = 0; i < items.length; i += 25) await writeChunk(items.slice(i, i + 25));
copied += items.length;
ExclusiveStartKey = page.LastEvaluatedKey;
} while (ExclusiveStartKey);
console.log(`copied ${copied} items`);The low-level client keeps every item in its typed wire form, so numbers and sets reach the target unchanged. What the script handles, and why:
BatchWriteItemcaps at 25 items or 16MB per call, so the script chunks, and a call can return unprocessed items you retry with exponential backoff (API reference).- Writes consume write capacity. On a provisioned target, throttled
writes come back as
UnprocessedItems, or as aProvisionedThroughputExceededExceptionwhen nothing in the batch succeeds (the SDK retries that). On-demand absorbs more but still caps each partition at 1,000 WCU / 3,000 RCU. Size the write load against the destination's capacity before you start. Scanreads the whole table and meters every item, the classic Query-vs-Scan cost, and pages throughLastEvaluatedKey; see pagination.- Not atomic. Items written while the scan runs can be missed. For a consistent
copy of a live table, take the snapshot from an S3 export (Approach 2),
or enable Streams before the scan, scan with
ConsistentRead: true, then replay the stream's changes onto the target, as the Scan docs describe. A consistent scan costs twice the reads. Stream records are kept for 24 hours, so the scan and the replay must finish inside that window; on a large table, use the S3 export snapshot instead (DynamoDB Streams).
Best for small tables or when you need to transform or filter during the copy. If the read half already exists as a DynoTable DynamoDB-JSON export, the script shrinks to the chunk-and-write loop.
Approach 2: Export to S3, then import to a new table
For large tables, DynamoDB's managed export to S3 plus import from S3 avoids hammering your capacity at all.
Export snapshots the table to an S3 bucket (how it works):
- Requires point-in-time recovery (PITR) enabled on the source table.
- Does not consume read capacity and has no impact on table performance: it reads from continuous backups, not the live table.
- Outputs DynamoDB JSON or Amazon Ion format. (The DynamoDB-JSON wire format is what lands in S3, type tags and all.)
- Can write to an S3 bucket owned by another account and in a different region.
You still call the export from the table's account. For another account's bucket,
add
--s3-bucket-owner <bucket-account-id>, and the bucket owner adds a bucket policy that lets your exporting role calls3:PutObject,s3:PutObjectAclands3:AbortMultipartUpload(requesting an export). - Supports full and incremental exports (incremental export GA, Sept 2023).
- Takes an optional filter: a key condition on one partition-key value, a filter expression, and a projection (filtered export). Only the key condition reduces the data DynamoDB reads; a filter expression is applied after the read.
For a copy from account 111122223333 to account 444455556666, the simplest layout
is a bucket in the target account: the source account exports into it, and the
target imports from its own bucket. Run this with the source account's credentials:
aws dynamodb export-table-to-point-in-time \
--table-arn arn:aws:dynamodb:us-east-1:111122223333:table/SourceTable \
--s3-bucket my-migration-bucket --s3-prefix copy \
--s3-bucket-owner 444455556666 \
--export-format DYNAMODB_JSON \
--filter-specification '{"KeyConditionExpression": "PK = :t",
"ExpressionAttributeValues": {":t": {"S": "TENANT#42"}}}' # omit for the whole tableAn older AWS CLI rejects --filter-specification with Unknown options; update the CLI
if you see that.
Import then builds a fresh table from that S3 data (how it works):
- Imports into a brand-new table only; you cannot import into an existing table.
- Does not consume write capacity on the new table.
- Accepts CSV, DynamoDB JSON, or Amazon Ion (optionally GZIP/ZSTD compressed).
- The source S3 bucket may be in another account or another region. For a bucket
the importing account doesn't own, add
S3BucketOwner=<bucket-account-id>to--s3-bucket-source, and the bucket owner grants your importing roles3:GetObjectands3:ListBucket. - You can define global secondary indexes at import time, queryable as soon as the import completes. Local secondary indexes are not supported: a source with LSIs needs Backup restore (Approach 3) or a scan+write into a target you create with the LSIs.
Point the import at the export's data folder,
s3://<bucket>/<prefix>/AWSDynamoDB/<export-id>/data/, where the export ID is the
last part of the export ARN
(requesting an import).
Run it with the target account's credentials; the bucket is that account's own, so
no owner parameter is needed:
aws dynamodb import-table --region eu-west-1 \
--s3-bucket-source S3Bucket=my-migration-bucket,S3KeyPrefix=copy/AWSDynamoDB/<export-id>/data/ \
--input-format DYNAMODB_JSON --input-compression-type GZIP \
--table-creation-parameters '{"TableName": "TargetTable",
"KeySchema": [{"AttributeName": "PK", "KeyType": "HASH"}, {"AttributeName": "SK", "KeyType": "RANGE"}],
"AttributeDefinitions": [{"AttributeName": "PK", "AttributeType": "S"}, {"AttributeName": "SK", "AttributeType": "S"}],
"BillingMode": "PAY_PER_REQUEST"}'This is the cleanest path for a large cross-account/cross-region migration where a point-in-time snapshot (not live data) is acceptable.
Approach 3: AWS Backup copy + restore
If you already use AWS Backup, it copies recovery points across accounts and regions (cross-account migration guide):
- In both accounts, open AWS Backup → Settings: enable Advanced features for Amazon DynamoDB backups, and turn on Cross-account backup. Without these the Copy step isn't available.
- Back up the source table into a backup vault.
- Copy the backup to a vault in the target account/region. That vault can't be
the default vault, and its access policy must allow
backup:CopyIntoBackupVaultfrom the source account, or the copy is denied (cross-account backup). - Restore it to a new table in the target.
Key constraints:
Cross-account copy requires both accounts to be in the same AWS Organization. If they aren't, use the S3 export/import path, whose bucket can belong to any account.
Restore always creates a new table; you can't restore over an existing one.
A full restore keeps the source's GSIs, LSIs, billing mode and provisioned capacity as recorded at backup time (how restores work). You can exclude indexes to save restore time and cost, but you can't add new ones at restore. Add a GSI afterwards; it backfills online (GSI vs LSI). On a provisioned table, also give the
Createblock aProvisionedThroughput:aws dynamodb update-table --table-name TargetTable \ --attribute-definitions AttributeName=GSI1PK,AttributeType=S AttributeName=SK,AttributeType=S \ --global-secondary-index-updates '[{"Create": {"IndexName": "GSI1", "KeySchema": [{"AttributeName": "GSI1PK", "KeyType": "HASH"}, {"AttributeName": "SK", "KeyType": "RANGE"}], "Projection": {"ProjectionType": "ALL"}}}]'Encryption. AWS Backup re-encrypts the copy with the destination vault's key. If the source table uses a customer managed KMS key, share that key with the target account (cross-account backup). At restore you pick the new table's encryption key in the target.
Approach 4: Global tables (live replication, not a one-time copy)
Global tables replicate a table across regions, and optionally across accounts (multi-account GA, Feb 2026), continuously. Any replica serves reads and writes (multi-active), with asynchronous, last-writer-wins replication (global tables docs).
Use it when you want the destination region to stay in sync indefinitely (DR, low-latency local reads), not for a clean one-time migration. Add a region to an existing table and DynamoDB backfills the existing data into the new replica.
The export half: pull the data with DynoTable
A hand-rolled scan loop is the most error-prone part of a small migration (dropped pages, mangled number precision, type tags stripped too early). DynoTable does that half from the Export dialog (⌘⇧E):
- Lossless: export the full filter match as JSON or NDJSON with Values: DynamoDB-JSON, the type-wrapped wire form that preserves large numbers (> 2⁵³) plain JSON corrupts. CSV is there too when the target isn't DynamoDB. See export to CSV for the format details.
- Scoped: the file export streams every item your query matches to disk, so
"copy only the
TENANT#42items to staging" is a filter. Its S3 destination builds the managed export's filter from the same query (Approach 2). - Large tables: exports detach and run in the background, streaming to disk row by row; a multi-gigabyte pull survives tab switches and app reloads.
- Verification after the load: open the source and then the target (switch
profiles for another account or region), scan each to the end with Run to end
and compare the item counts the grid reports, then spot-check sample records without
writing a verification script. Don't compare the Table Overview counts: they're
DescribeTable's estimate, refreshed about every six hours (table size & item count).
DynoTable can also do the load: its table data import writes a DynamoDB-JSON or NDJSON file into an existing destination table exactly (paid plans; it is not undoable). For a large table, or one that must arrive with its indexes, use AWS tooling (a write script, S3 import, or Backup restore: Approaches 1 to 3 above).
Operational gotchas (all approaches)
- GSIs aren't free to recreate. A scan+write copy doesn't carry indexes: you define them on the target and they backfill (and cost) separately. Plan your GSI vs LSI layout on the destination up front; LSIs can only be created at table-creation time (LSI docs).
- Capacity mode doesn't transfer on scan+write or S3 import. The new table starts with whatever mode you set (a Backup restore keeps the source's, unless you override it). Estimate the write load before a scan+write copy: size a representative item with the item-size calculator and multiply by item count to ballpark WCUs.
- TTL, streams, auto-scaling, and tags are table settings, not
data. No copy method carries all of them. Read them from the source with
describe-table,describe-time-to-liveandlist-tags-of-resource, then apply them withupdate-time-to-live,update-table --stream-specification,tag-resource, andapplication-autoscaling register-scalable-target/put-scaling-policy. - DynamoDB JSON ≠ plain JSON. Exports and scans emit type-tagged DynamoDB-JSON; if you're transforming en route, the DynamoDB JSON converter handles the marshaling.
- Verify before cutover.
DescribeTable's count is up to six hours stale, so a fresh target can legitimately report zero. Count exactly withaws dynamodb scan --table-name TargetTable --select COUNT(it reads the whole table), or compare the import'sImportedItemCount, then spot-check records on both sides.
FAQ
Is there an AWS CLI command to copy a DynamoDB table?
No. There's no native copy-table command. You combine scan + batch-write-item,
or use the managed export/import or AWS Backup features.
How do I copy a DynamoDB table to another account? Three options: a scan+write script with credentials for both accounts, an S3 export/import (the bucket can be cross-account), or AWS Backup copy+restore (both accounts must be in the same AWS Organization).
How do I copy a DynamoDB table to another region? S3 export/import and AWS Backup both support cross-region. For ongoing cross-region sync rather than a one-time copy, add a global-table replica in the target region.
Does copying a table copy its indexes? AWS Backup restore keeps GSIs and LSIs; S3 import lets you define GSIs (not LSIs) on the new table; a scan+write script copies none, so you create indexes on the target yourself, and they backfill separately.
Can I import into an existing DynamoDB table? No. DynamoDB's S3 import and AWS Backup restore both create a new table. To merge into an existing table, use a scan+write script.
Can I copy only part of a table?
Yes. The managed S3 export takes a filter (--filter-specification), so a filtered
export followed by an import copies a subset into a new table. Backup restore is
full-table only. To merge a subset into an existing table, export the filter match
from DynoTable as DynamoDB-JSON or script a filtered scan, then write
the subset to the target.
A GUI makes the cutover easier to check: export exactly the items you're moving, then open the source and the target, scan each to the end and compare the counts and a few sample records after the copy, and run ad-hoc checks without writing a scan script. Download DynoTable to run the export-and-verify half of a migration across accounts and regions.