{"id":12750,"date":"2022-04-22T23:32:49","date_gmt":"2022-04-23T05:32:49","guid":{"rendered":"https:\/\/www.supportpro.com\/blog\/?p=12750"},"modified":"2026-03-05T23:32:02","modified_gmt":"2026-03-06T05:32:02","slug":"migrating-data-between-amazon-s3-buckets-using-aws-datasync","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/migrating-data-between-amazon-s3-buckets-using-aws-datasync\/","title":{"rendered":"How to Transfer Data Between Amazon S3 Buckets Using AWS DataSync"},"content":{"rendered":"<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault.jpg\" data-rel=\"penci-gallery-image-content\" ><img fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-1024x576.jpg\" alt=\"\" class=\"wp-image-12751\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-1024x576.jpg 1024w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-300x169.jpg 300w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-768x432.jpg 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-1170x658.jpg 1170w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault-585x329.jpg 585w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/04\/maxresdefault.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n<\/div>\n\n\n<p>Migration of data is an inevitable process in website hosting. In conventional methods, we will do the migrations manually across the servers, which is hectic in a way. In AWS we have a new feature called AWS DataSync which will transfer the data in S3 buckets between two AWS instances, regions, accounts, etc. With DataSync we can do a one-time data transfer and also can schedule the migration whenever we needed.<\/p>\n\n\n\n<p>We will see some examples of data transfer below, thus we can have a proper understanding of the AWS DataSync.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Transferring data within the same Amazon S3 account<\/strong><\/h3>\n\n\n\n<p>Select the DataSync page in the AWS console and create a task using the \u2018Task\u2019 option in the left menu bar. Then choose \u2018Create a new location\u2019 and for location type select \u2018Amazon S3\u2019 from the source location option.&nbsp;<\/p>\n\n\n\n<p>After that, we have to select the AWS region, S3 bucket. Storage class and the directory from which we have to transfer the data. Then for the IAM role, we have to click on the Autogenerate button.<\/p>\n\n\n\n<p>The same is followed in destination location options. Choose the destination accordingly with the Location type as \u2018Amazon S3\u2019<\/p>\n\n\n\n<p>After that we need to name the task that we are going to execute.<\/p>\n\n\n\n<p>After the last check of the configurations, we have input earlier, we need to start the task by clicking on the \u2018Create Task\u2019 button.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Transferring data across accounts<\/strong><\/h3>\n\n\n\n<p>The first step we need to do is<strong> <\/strong>to create the necessary IAM role in the destination AWS account. This is to access the source S3 bucket, then we need to attach a new policy for the created IAM role in the source S3 bucket.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>{&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Version&#8221;: &#8220;2012-10-17&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Statement&#8221;: [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Action&#8221;: [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:GetBucketLocation&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:ListBucket&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:ListBucketMultipartUploads&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Effect&#8221;: &#8220;Allow&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Resource&#8221;: &#8220;arn:aws:s3:::SOURCEBUCKET&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Action&#8221;: [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:AbortMultipartUpload&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:DeleteObject&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:GetObject&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:ListMultipartUploadParts&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:PutObjectTagging&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:GetObjectTagging&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;s3:PutObject&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;],&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Effect&#8221;: &#8220;Allow&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Resource&#8221;: &#8220;arn:aws:s3:::SOURCEBUCKET\/*&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;]}<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>After that, we need to add the trust relationship in the IAM role.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>{&nbsp;&nbsp;&#8220;Version&#8221;: &#8220;2012-10-17&#8221;,&nbsp;&nbsp;&#8220;Statement&#8221;: [&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Effect&#8221;: &#8220;Allow&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Principal&#8221;: {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Service&#8221;: &#8220;datasync.amazonaws.com&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Action&#8221;: &#8220;sts:AssumeRole&#8221;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;]}<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>From the AWS command line, we need to create S3 bucket location in the source for DataSync. Please have a note on the Amazon resource names(ARN) while creating the DataSync location and then use it on the following S3 bucket policy.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>{&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Version&#8221;: &#8220;2012-10-17&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Statement&#8221;: [&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Sid&#8221;: &#8220;BucketPolicyForDataSync&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Effect&#8221;: &#8220;Allow&#8221;,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;Principal&#8221;: {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n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bsp;&nbsp;&nbsp;&nbsp;&#8220;arn:aws:s3:::SOURCEBUCKET\/*&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;]}<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>Now using the IAM role specified in the source S3 bucket policy, open the command line and run the following for the ARN.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>aws sts get-caller-identity<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>aws datasync create-location-s3 &#8211;s3-bucket-arn arn:aws:s3:::SOURCEBUCKET &#8211;s3-config&nbsp;&#8216;{&#8220;BucketAccessRoleArn&#8221;:&#8221;arn:aws:iam::DEST-ACCOUNT-ID:role\/DEST-ACCOUNT-ROLE&#8221;}&#8217;<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>This will give a similar output to the following, which means the source S3 bucket has been created.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><div class=\"pcrstb-wrap\"><table><tbody><tr><td>{&#8220;LocationArn&#8221;: &#8220;arn:aws:datasync:Region:DEST-ACCOUNT-ID:location\/loc-xxxxxxxxxxxxxx&#8221;}<\/td><\/tr><\/tbody><\/table><\/div><\/figure>\n\n\n\n<p>Except for the following location choose option the other steps are the same as we did on the data transfer on the same account. Since we have already created the source and destination locations we need to choose the location as the existing source location.<\/p>\n\n\n\n<p>After configuring the source and destination, click on the \u2018Create task\u2019 which will start the data transfer.<\/p>\n\n\n\n<p>If you require help, contact <a href=\"https:\/\/supportpro.com\/requestquote.php\" target=\"_blank\" rel=\"noreferrer noopener\">SupportPRO Server Admin<\/a><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Migration of data is an inevitable process in website hosting. In conventional methods, we will do the migrations manually across the servers, which is hectic in a way. In AWS&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-12750","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/12750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=12750"}],"version-history":[{"count":5,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/12750\/revisions"}],"predecessor-version":[{"id":15924,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/12750\/revisions\/15924"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=12750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=12750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=12750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}