Skip to main content
This walkthrough demonstrates how to use AWS DataSync to migrate files from an on‑premises NFS file server into AWS. The lab screenshots and steps below show NFS → S3, but the same DataSync concepts apply when using EFS as the destination.
A simple architecture diagram showing a corporate data center pipeline: App Server -> NFS Server -> DataSync Agent. The agent transfers data to AWS DataSync which then copies it into an AWS S3 bucket.
Overview
  • Source: NFS server reachable from the source network (in this lab simulated in a separate VPC on AWS).
  • Agent: DataSync agent running in the same network (EC2 in this lab) so it can mount the NFS export.
  • Destination: Amazon S3 (or EFS) where DataSync will copy the files.
Quick architecture summary: Servers and mounts The lab supplies pre-deployed instances. The application server mounts the NFS export and reads/writes files that we will copy using DataSync.
A screenshot of the AWS EC2 Instances dashboard showing several running EC2 instances, with "appServer" selected. The details pane shows the selected instance's ID, IP addresses and status (Running).
On the application server confirm the NFS export is mounted. Example df -h output (mounted at /mnt/data):
The export contains an images folder with many JPEG files — these are the files we will migrate:
S3 destination The destination bucket for this lab is named DataSync-KodeKloud (pre-created). The DataSync task will copy the images folder contents into this bucket.
A screenshot of the Amazon S3 console showing an account snapshot and a list of three S3 buckets. The bucket names, AWS regions, access settings, and creation dates are visible in the table.
Deploying and registering the DataSync agent DataSync moves data using an agent that runs inside the source network. Agents can be deployed on VMware, KVM, Hyper‑V, EC2, Snowcone, or Outposts. This lab uses an EC2-based agent.
  1. Find the latest DataSync AMI via SSM Parameter Store (run in CloudShell or any machine with AWS CLI configured). Replace the region with the region where the agent and source are reachable:
Sample (truncated) output:
  1. Launch the EC2 agent
  • Use the returned AMI ID to launch an instance (you can open the EC2 launch wizard pre-populated with the AMI): https://console.aws.amazon.com/ec2/v2/home?region=us-east-1#LaunchInstanceWizard:ami=ami-0abcdef1234567890
  • For production throughput, DataSync recommends instance types such as m5.2xlarge, m5.4xlarge, or c5n.2xlarge. For testing, smaller instances may suffice. This lab used m5.2xlarge.
  • Choose key pair, VPC/subnet, and security group rules that allow the agent to reach:
    • NFS server (TCP port 2049)
    • Outbound HTTPS to DataSync service endpoints
A screenshot of the AWS EC2 "Launch Instance" console showing instance configuration details (instance type m5.2xlarge), a key pair selection dropdown, and a right-hand summary panel with storage, security group and a "Launch instance" button.
This lab used permissive security group rules for simplicity (NOT recommended for production). Ensure the agent can access the NFS server and has outbound internet access for DataSync APIs.
A screenshot of the AWS EC2 "Launch Instance" configuration page showing subnet, auto-assign IP, and security group settings (including an inbound rule allowing all traffic from 0.0.0.0/0). A right-hand summary lists the AMI, instance type (m5.2xlarge), storage, and a visible "Launch instance" button.
Do not leave security groups open in production. Restrict inbound access to the DataSync agent (source network CIDRs) and only allow necessary outbound traffic (DataSync endpoints). Also limit SSH access to trusted IPs.
  1. Register the agent in the DataSync console
  • Open the DataSync console and choose to create/register an agent.
  • Select EC2 as the deployment type.
  • If required, enable the public service endpoint.
  • Click “Get key” and provide the agent’s public IP (or the private IP reachable by the console). The console will contact the agent and retrieve an activation key to complete registration.
Screenshot of an AWS console page (DataSync/agent setup) showing a successfully retrieved activation key and the agent address 18.234.228.236. The lower part shows an optional "Agent name" field (partially filled with "datas") and a "Tags - optional" section.
Creating DataSync locations A DataSync transfer requires a source location and a destination location. A location describes where data comes from or goes to.
  1. Create the NFS source location
  • Location type: Network File System (NFS)
  • Agent: select the registered agent
  • NFS server: 10.11.12.182 (lab example)
  • Mount path: /media/data (the export containing images)
This mount path matches the export mounted on the application server.
A screenshot of the AWS DataSync "Create location" configuration page showing "Network File System (NFS)" selected, an agent chosen, NFS server IP 10.11.12.182, and mount path "/media/data". The bottom of the page shows a "Create location" button.
  1. Create the S3 destination location
  • Location type: Amazon S3
  • Bucket: DataSync-KodeKloud
  • Storage class: Standard (or choose a different storage tier)
  • IAM role: auto-generate a role for DataSync (or select an existing role with appropriate S3 permissions)
After creating the S3 location, DataSync will display the location details and confirm the IAM role used to write to the bucket.
A screenshot of the AWS DataSync console showing a created S3 location (loc-06d8cab90c1f92c81) with details like the S3 bucket name (datasync-kodekloud), storage class, and bucket IAM role. A green banner at the top confirms the location and IAM role were successfully created.
Create and run a DataSync task With both locations created, create a DataSync task to control what and how data is transferred. Task configuration highlights:
  • Source location: NFS
  • Destination location: S3
  • Task name: e.g., copy-NFS-to-S3
  • Options:
    • Verify data after transfer (recommended for integrity)
    • Bandwidth limits to avoid saturating links
    • Include/exclude filters to pick subfolders or filename patterns
    • Transfer mode and metadata handling
    • Enable CloudWatch logging and/or schedule recurring transfers
The console’s transfer configuration page lets you toggle verification, set bandwidth, and configure additional settings.
A screenshot of the AWS DataSync console showing "Data transfer configuration" settings, including options for verifying data, bandwidth limits, data-to-scan (entire source or specific files), transfer mode, and file-handling checkboxes. The page displays radio buttons, checkboxes, and expandable "Additional settings" and "Schedule" sections.
Start the task execution
  • Click “Start” (use defaults or override options).
  • Monitor the task execution status: Launching → Transferring → Completed (or Failed).
  • Execution details show metrics: files transferred, bytes transferred, throughput, and elapsed time.
When the task finishes, verify the objects in the destination S3 bucket — the images folder and JPG files should be present.
A screenshot of the Amazon S3 web console showing a bucket's Objects view with a list of JPG files named like 00005.jpg, 00006.jpg, etc. The table displays type, last modified timestamps, file sizes and storage class, with controls for Upload, Create folder and Actions.
Best practices and production considerations
  • Deploy the agent in the same network as your source file system and restrict network access via security groups and network ACLs.
  • Choose agent EC2 instance sizes based on expected throughput (see DataSync documentation for guidance).
  • Use lifecycle policies and appropriate S3 storage classes for long-term cost optimization.
  • Monitor CloudWatch logs and metrics for transfer health and performance.
  • For large or recurring migrations, consider scheduling tasks and tuning bandwidth limits to avoid impacting production networks.
For production: tighten security group rules to limit agent access, pick instance types based on throughput requirements (e.g., m5.2xlarge, m5.4xlarge, c5n.2xlarge for heavy workloads), and plan S3 lifecycle rules or storage classes to control long‑term costs.
Summary
  • Deploy a DataSync agent within the network that can access your source file system.
  • Create DataSync locations for source (NFS) and destination (S3 or EFS).
  • Create and run a task to define which data to transfer and how.
  • Monitor executions and verify the destination after completion.
Links and references

Watch Video