Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Copy files from one EBS to Another EBS

The problem is simple.

I need to copy the files from one EBS to Another without passing the files through my local machine. Is this possible? If so how?

like image 828
dade Avatar asked Jan 16 '12 13:01

dade


People also ask

Can I attach EBS volume to another instance?

You can attach an available EBS volume to one or more of your instances that is in the same Availability Zone as the volume.

How do I copy an EBS snapshot from one region to another?

In the navigation pane, choose Snapshots. Select the snapshot to copy, and then choose Copy from the Actions list. In the Copy Snapshot dialog box, update the following as necessary: Destination region: Select the Region where you want to write the copy of the snapshot.


1 Answers

In order to copy files from one EBS volume to another EBS volume, both volumes will (at some point) need to be attached to an instance, though not necessarily the same instance. There are a lot of ways to do this if you allow for multiple instances and/or temporarily storing the files on a third storage option, but without constraints, and assuming the volumes are not currently attached to instances, a simple solution would be:

  1. Start a temporary instance. Use a larger size for higher IO bandwidth.

  2. Attach both EBS volumes to the instance and mount them as, say, /vol1 and /vol2

  3. Copy the files from /vol1 to /vol2 (perhaps using something like: rsync -aSHAX /vol1/ /vol2/ )

  4. Unmount the volumes, detach the EBS volumes, terminate the temporary instance.

If you have additional constraints, you should update your question to specify exactly what your environment is and what you're trying to do.

[Followup based on the error you are seeing]

The EC2 instance and EBS volume must exist in the same EC2 region and availability zone for the volume to be attached to the instance. If they are not, then you may want to create a temporary instance in the EBS volume's availability zone and use something like rsync to copy files between two instances.

like image 159
Eric Hammond Avatar answered Sep 20 '22 09:09

Eric Hammond