自动化 Amazon EBS 快照 任何人在 linux 上都有一个很好的脚本或解决方案 [英] Automating Amazon EBS snapshots anyone have a good script or solution for this on linux

查看:19
本文介绍了自动化 Amazon EBS 快照 任何人在 linux 上都有一个很好的脚本或解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望这是相当常规的,但找不到自动创建管理 EBS 快照的简单方法.

希望 AWS 控制台中有一个 shceduler.. 可惜现在还没有.

对于如何最好地从 Ubuntu 执行此操作的任何建议,我们将不胜感激.

谢谢

解决方案

您可以轻松编写脚本来为您执行此操作.

  1. 设置EC2 命令行 API 工具
  2. 设置 EC2_CERTEC2_PRIVATE_KEY 以便能够使用 API 工具
  3. 解析ec2-describe-snapshots
  4. 的结果
  5. 删除相应的快照

结果类似于:

<前>快照 snap-xxxxxxxx vol-xxxxxxxx 已完成 2009-08-26T07:39:33+0000 100%

然后您可以对日期进行一些解析和排序,然后开始删除较旧的快照.

注意:我不知道我们是否可以信任排序顺序,但除了从旧到新之外,我从未见过它以任何其他方式排序.

要删除快照,请使用 ec2-delete-snapshot snap-xxxxxxxx.

剩下的我留给你作为一个简单的 Bash 脚本,你可以每天或从 cron 调用它.

I'd expect this to be fairly routine, but cannot find a simple approach for creating an managing EBS snapshots automatically.

Was hoping there'd be a shceduler in the AWS console.. alas not yet.

Would appreciate any suggestions as to how best to do this on from Ubuntu.

Thanks

解决方案

You can easily script something to do this for you.

  1. setup the EC2 commandline API tools
  2. set EC2_CERT and EC2_PRIVATE_KEY in order to be able to use the API tools
  3. parse the results of ec2-describe-snapshots
  4. delete the appropriate snapshots

The results look something like:

SNAPSHOT    snap-xxxxxxxx   vol-xxxxxxxx    completed   2009-08-26T07:39:33+0000    100%

You can then do some parsing of the dates and sorting and start removing the older snapshots.

NOTE: I don't know if we can trust the sort order but I've never seen it sort any other way than oldest to newest.

To delete a snapshot, use ec2-delete-snapshot snap-xxxxxxxx.

The rest I leave to you as a simple Bash script that you can call daily or however often you need from cron.

这篇关于自动化 Amazon EBS 快照 任何人在 linux 上都有一个很好的脚本或解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆