Instance store的备份

方式是创建一个ebs卷,挂到机器上,然后将instance store中的数据copy到这个卷,最后对这个EBS卷进行备份。

创建新的 EBS 卷并迁移数据

  1. 创建 EBS 卷 。选择一个足以容纳要迁移数据的大小。
  2. 将 EBS 卷连接 到您的实例。
  3. 使该卷可供操作系统使用,然后在该卷上创建兼容的文件系统。对于 Linux 实例,请参阅使 Amazon EBS 卷可在 Linux 上使用 。对于 Windows 实例,请参阅使 Amazon EBS 卷可在 Windows 上使用
  4. 使用磁盘管理或迁移工具复制操作系统的数据,例如适用于 Linux 的 rsync 或适用于 Windows 的 robocopy。有关 rsync 的详细信息,请参阅 Linux 手册页上的 rsync(1) 。有关 robocopy 的详细信息,请参阅 Microsoft 文档中的 robocopy

注意: 在确保复制操作成功并完成之前,请保持两个卷都可用。在新 EBS 卷可用于您的实例之前,您可能需要进行其他配置工作。

具体步骤:

Make the volume available to your operating system, and create a compatible file system on the volume. To do so:

List all volumes. Here the EBS volume we attached is denoted as xvdf.

EBS volumes

View file system on EBS volume

EBS volumes

sudo file -s /dev/xvdf

Ideally it should not have any file system configured, as shown in image above. If you get a response as a Linux file system then you can skip next step.

Setup file system on EBS volume:

sudo mkfs -t ext4 /dev/xvdf

EBS volume

The above command will help format the EBS volume to a ext4 file system ideal for Linux instances. For Windows, refer to this link .

Create mount point/directory for EBS volume.

EBS volumes

You can choose any location for mount directory, here its /opt.

Next, mount EBS volume with help of fstab. Keep in mind that before you make changes it recommended to back up your existing fstab file.

In fstab file, enter device name followed by mount point.

The last three fields on this line are the file system mount options, the dump frequency of the file system, and the order of file system checks done at boot time.

EBS volumes

Once you’ve made the changes in the fstab file, now you can execute the following command to mount all the entries in the fstab file:

 sudo mount -a

After successfully mounting the volume you should see following output for the df command:

EBS volumes

Now transfer all your data to mount directory on EBS volume. You can use the rsync utility to transfer all the data on Linux instances:

sudo rsync -zvh /path-to-your-data.tar.gz /path-to-mount-directory

EBS volumes

That’s it! This will transfer all your data. Once you’re done with the transfer you can unmount and detach the EBS volume. To unmount, use the following command:

sudo umount /dev/xvdf 

Things to keep in mind: It’s a best practice to keep both volumes available until you’re sure that the copy operation has succeeded.

If you’re using Windows OS, refer to the following document to achieve same on an Windows instance store volume.

If you would like to continually back up data from ephemeral storage to EBS you can use tools such as rsync , lsyncd for Linux, and robocopy for Windows. You can also make automated backups of an EBS volume by taking snapshots.

参考: https://bluexp.netapp.com/blog/backing-up-ephemeral-storage-to-aws-ebs