How to Copy files from one EBS to Another EBS
Asked Answered
L

1

10

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?

Lucent answered 16/1, 2012 at 13:31 Comment(0)
L
11

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.

Larrisa answered 16/1, 2012 at 20:35 Comment(6)
The problem is with "Attach both EBS volumes to the instance and mount them as, say, /vol1 and /vol2" From the console, when i go to EBS, and i right click on the new EBS volume, I can only attach that volume to the instance it was created with. I cant seem to have it attached to a new Instance :( Any thoughts why this is the case?Lucent
dade: I added a followup in the answer above.Larrisa
Extra points to this answer because the solution doesn't use the network, so you save money on tranfers.Slosberg
@JavierConstanzo: This solution does use the network, as EBS volumes are mounted over the network. It does not cost you any money in network transfers, as all network transfers within an EC2 availability zone are free (even between instances). However, it will cost you in IO operations, though perhaps negligible depending on the size of your volumes.Larrisa
I am trying to upgrade PhP to 8 but the OS is also outdated and can't perform the task directly. However I d'like to keep scripts and conf from the current instance. Is it possible to start fresh from new OS and Php version > mount the old EBS volume > finality synch the app environment without breaking the workflow? Is there a checklist somewhere for that? KindlyRema
An even better alternative for the future would be not to synch all in one but instead keep the 2 volumes, one for the OS and the other for PhP/Apps, but I don't know if it is recommended or even doable. If yes what would you recommend? Thanks in advance for your time.Rema

© 2022 - 2024 — McMap. All rights reserved.