Home / AWS

AWSTroubleshootingIntermediate

AWS DataSync task execution failed: offline agents, permission errors and verification mismatches

Find which phase of a DataSync task execution failed, read the real error, and fix offline agents, NFS/SMB/S3 permission errors and verification failures without recopying everything.

Deepak Bhardwaj7 min read

Applies toAWS DataSync (agent-based and agentless locations), NFS, SMB, Amazon S3, Amazon EFS and FSx locations, AWS CLI v2

Symptom

A DataSync task execution ends in ERROR, sits in LAUNCHING or PREPARING for a long time, or reports SUCCESS for the transfer but fails at the end with a verification error. Usually it happens on the night of a migration cutover sync.

Before you change anything, work out which phase failed. Each phase has a different set of causes.

Find the failed phase and the real error

A task execution goes through QUEUED, LAUNCHING, PREPARING, TRANSFERRING and VERIFYING, then ends in SUCCESS or ERROR. Cancelled runs pass through CANCELLING.

# Latest executions for a task
aws datasync list-task-executions \
  --task-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123 \
  --query 'TaskExecutions[-5:]' --output table

# Phase-by-phase result of one execution
aws datasync describe-task-execution \
  --task-execution-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123/execution/exec-0def456 \
  --query '{Status:Status,Prepare:Result.PrepareStatus,Transfer:Result.TransferStatus,Verify:Result.VerifyStatus,Code:Result.ErrorCode,Detail:Result.ErrorDetail,Files:FilesTransferred,Bytes:BytesTransferred}'

Result.ErrorCode and Result.ErrorDetail give you a summary. They often don't name the file or path that caused the failure. For that you need task logging:

aws datasync describe-task --task-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123 \
  --query '{Status:Status,LogGroup:CloudWatchLogGroupArn,Options:Options}'

If CloudWatchLogGroupArn is empty or Options.LogLevel is OFF, turn logging on before the next run. BASIC logs errors. TRANSFER logs every file, which is what you want while debugging but is noisy on large datasets.

aws datasync update-task \
  --task-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123 \
  --cloud-watch-log-group-arn arn:aws:logs:eu-west-1:111122223333:log-group:/aws/datasync \
  --options LogLevel=TRANSFER

The log group needs a resource policy that lets datasync.amazonaws.com create log streams and put log events. If you created the task in the console, that policy is usually already there. With the CLI or IaC you have to add it yourself.

Use Logs Insights to find the failing paths:

fields @timestamp, @message
| filter @message like /ERROR/
| sort @timestamp desc
| limit 100

Symptom, cause and fix

Symptom Likely cause Fix
Stuck in LAUNCHING, or error says the agent is unavailable Agent OFFLINE, or it can't reach the DataSync endpoint on TCP 443 Check agent status, firewall/proxy, and the VPC endpoint security group
PREPARING fails quickly with permission or mount errors NFS export, SMB credentials or S3 IAM role is wrong Fix the location (see below) and rerun
PREPARING takes hours Millions of small files to scan on both sides Use include filters or split the task by top-level folder
Transfer SUCCESS, verify ERROR Source files changed during the run, or metadata differs Rerun when the source is quiet, or change VerifyMode
S3 source objects skipped or failing Objects in archive storage classes, or SSE-KMS key access missing Restore objects first and grant the role kms:Decrypt
Destination has extra or missing files after a sync PreserveDeletedFiles and OverwriteMode aren't set the way you expect Review the options before the cutover run

Fix: agent offline or unreachable

aws datasync list-agents --query 'Agents[].{Name:Name,Status:Status,Arn:AgentArn}' --output table

aws datasync describe-agent --agent-arn arn:aws:datasync:eu-west-1:111122223333:agent/agent-0abc123 \
  --query '{Status:Status,LastConnection:LastConnectionTime,Endpoint:EndpointType,Private:PrivateLinkConfig}'

If the agent is OFFLINE:

  1. Check that the agent VM or EC2 instance is running and that its clock and DNS are working.
  2. Check that the agent can reach the DataSync service endpoint on TCP 443. With a VPC (PrivateLink) endpoint, the endpoint's security group must allow 443 from the agent. Check the current network requirements page for any other ports your endpoint type needs.
  3. Log in to the agent's local console and run its network connectivity test. It checks reachability to the activated endpoint.
  4. If a proxy or TLS-inspecting firewall sits in the path, exclude the agent from inspection.

Port 80 is only used during activation to fetch the activation key. Once the agent is activated, you don't need port 80 open to it.

Warning

Don't delete and re-create an agent mid-migration just because it is offline. Tasks are tied to the agent through their locations. A new agent means new locations and tasks, so you lose your execution history and incremental behaviour during troubleshooting. Fix connectivity first.

Fix: location permission errors

NFS

  • The agent mounts the export on TCP 2049 (NFS 4.x), or on 111 and 2049 for NFS 3.x.
  • The export must allow the agent's IP. With root_squash, DataSync reads as an unprivileged user and fails on files that user can't read. For a full-fidelity copy, export with no_root_squash to the agent's IP only.
  • Test from a Linux host on the same subnet as the agent:
showmount -e nfs01.corp.example.com
sudo mount -t nfs -o nfsvers=4.1 nfs01.corp.example.com:/exports/projects /mnt/test && ls /mnt/test | head

SMB

  • The agent connects on TCP 445 (or 139).
  • The location user needs read access to every folder. To copy NTFS ACLs and ownership, it also needs the rights to read security descriptors. Membership of the file server's Backup Operators group is the usual way to give it those rights.
  • An expired or rotated password on the service account is a common cause of a run that worked last week. Update the location:
aws datasync update-location-smb \
  --location-arn arn:aws:datasync:eu-west-1:111122223333:location/loc-0abc123 \
  --user svc-datasync --domain CORP --password 'NEW-PASSWORD'

Amazon S3

The S3 location uses an IAM role that DataSync assumes. Check that the trust policy allows datasync.amazonaws.com, and that the role has bucket-level actions (s3:GetBucketLocation, s3:ListBucket, s3:ListBucketMultipartUploads) plus object-level read/write actions on arn:aws:s3:::bucket/*. If the bucket uses SSE-KMS, the role needs kms:Decrypt and kms:GenerateDataKey on the key. A bucket policy or SCP that denies everything except named roles also blocks DataSync.

aws datasync describe-location-s3 --location-arn arn:aws:datasync:eu-west-1:111122223333:location/loc-0s3abc \
  --query '{Uri:LocationUri,Role:S3Config.BucketAccessRoleArn,Class:S3StorageClass}'
aws iam get-role --role-name datasync-s3-access --query 'Role.AssumeRolePolicyDocument'

Fix: verification failures

The verification mode decides what is checked at the end of a run:

VerifyMode What it checks When to use
POINT_IN_TIME_CONSISTENT The whole source against the whole destination Final cutover sync, with the source frozen
ONLY_FILES_TRANSFERRED Only the files copied in this run Repeated incremental syncs while users are still working
NONE Only the integrity checks made during transfer Rarely; when you verify some other way

Most verification errors in the middle of a migration happen because users are still writing to the source. A file that changes after DataSync copied it no longer matches. Switch the incremental runs to ONLY_FILES_TRANSFERRED and keep the full check for the final run after you set the share read-only:

aws datasync start-task-execution \
  --task-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123 \
  --override-options VerifyMode=ONLY_FILES_TRANSFERRED

A metadata mismatch (for example MetadataDiffers on S3 sources) means content matched but attributes did not. The logs name the attribute. Fix it at the source, or adjust the metadata options, then rerun. The default TransferMode=CHANGED copies only what differs, so the rerun is fast.

Caution

PreserveDeletedFiles=REMOVE deletes files from the destination that no longer exist at the source. If the task points at the wrong source folder, or an empty mount, one run can wipe the destination. Confirm the source path and file count in EstimatedFilesToTransfer before enabling it, and keep destination backups or S3 versioning on during the migration.

Rerun only what failed

You don't need to start over. Running the same task again with TransferMode=CHANGED copies only new and changed files. To retry one folder after you fix its permissions, use an include filter:

aws datasync start-task-execution \
  --task-arn arn:aws:datasync:eu-west-1:111122223333:task/task-0abc123 \
  --includes FilterType=SIMPLE_PATTERN,Value=/finance/2026

Prevent it next time

  • Turn on CloudWatch logging (BASIC at minimum) when you create every task, not after the first failure.
  • Alarm on agent status and failed executions. An EventBridge rule on DataSync task execution state changes to ERROR can notify the migration channel.
  • Run a test sync a few days before cutover so permission problems show up early.
  • Keep the SMB service account's password out of normal rotation, or update the location as part of the rotation.
  • Split very large shares into several tasks by top-level folder. Prepare is faster, and one bad folder doesn't block everything else.