推广 热搜: 可以  搜索引擎  企业  page  个数  百度  使用  音视频  选择  父亲 

使用awscli创建ec2自动快照(全量备份)

   日期:2024-12-16     移动:http://ww.kub2b.com/mobile/quote/3945.html

awscli介绍

官方说明:The AWS Command Line Interface is a unified tool to manage your AWS services.

基本语法为:aws [options] <command> <subcommand> [parameters]

选项

--debug (boolean)

打开debug日志.

--endpoint-url (string)

使用指定的url替换默认url.

--no-verify-ssl (boolean)

默认情况,aws cli使用 SSL连接aws服务,每个SSL连接 awscli都会去认证SSL 证书,此选项更改连接是不去认证。

--no-paginate (boolean)

取消自动分页

--output (string)

输出格式.

json

text

table

--query (string)

用于筛选响应数据的 JMESPath 查询.

--profile (string)

使用凭据文件中的特定配置文件.

--region (string)

使用指定region替换配置文件、环境变量中的设置

--version (string)

显示awscli版本号

--color (string)

打开、关闭输出颜色控制.

on

off

auto

--no-sign-request (boolean)

不对请求进行签名认证。如果使用了此参数, 则不会加载凭据.

--ca-bundle (string)

验证 SSL 证书时要使用的 CA 证书捆绑。替换配置/环境设置。

--cli-read-timeout (int)

最大套接字读取时间 (秒)。如果该值设置为 0, 则套接字读取将被阻塞, 而不是超时。

--cli-connect-timeout (int)

最大套接字连接时间 (秒)。如果该值设置为 0, 则套接字读取将被阻塞, 而不是超时。

ec2 ebs快照

使用awscli创建ec2 ebs快照非常方便,使用ec2命令中的create-snapshot即可

语法

  create-snapshot [--description <value>] --volume-id <value> [--dry-run | --no-dry-run] [--cli-input-json <value>] [--generate-cli-skeleton <value>]

创建快照

如给卷 ID 为  创建快照并添加描述.

命令:

aws ec2 create-snapshot --volume-id vol-1234567890abcdef0 --description "This is my root volume snapshot."

输出:

{    "Description": "This is my root volume snapshot.",    "Tags": [],    "VolumeId": "vol-1234567890abcdef0",    "State": "pending",    "VolumeSize": 8,    "StartTime": "2014-02-28T21:06:01.000Z",    "OwnerId": "012345678910",    "SnapshotId": "snap-066877671789bd71b" }

全量备份

由于ebs快照为增量快照,其实也不需要删除原来的快照,删除原来的快照也不会释放多余的存储空间,新的快照仍然会使用原快照的存储的数据,实现完整数据备份。

我的全量备份策略如下

1、每周一次ebs快照,每个ebs仅保留两周(两个)快照

2、每个快照的打上标签,标签为ec2 Name标签+卷ID+备份时间

3、每个快照描述为 : 备份时间+UTC create snapshot for ec2 标签 卷 ID by awscli用户 on host: 执行命令用户@执行命令服务器名。

4、删除已不存在卷(实例删除,卷删除)的历史自动快照,不影响手动快照

用到命令

aws iam :https://docs.aws.amazon.com/cli/latest/reference/iam/index.html

aws ec2 describe-instances :https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-instances.html

aws ec2 create-snapshot : https://docs.aws.amazon.com/cli/latest/reference/ec2/create-snapshot.html

aws ec2 create-tags : https://docs.aws.amazon.com/cli/latest/reference/ec2/create-tags.html

aws ec2 delete-snapshot : https://docs.aws.amazon.com/cli/latest/reference/ec2/create-snapshot.html

具体实现

本文地址:http://ww.kub2b.com/quote/3945.html     企库往 http://ww.kub2b.com/ ,  查看更多

特别提示:本信息由相关用户自行提供,真实性未证实,仅供参考。请谨慎采用,风险自负。


0相关评论
相关最新动态
推荐最新动态
点击排行
网站首页  |  关于我们  |  联系方式  |  使用协议  |  版权隐私  |  网站地图  |  排名推广  |  广告服务  |  积分换礼  |  网站留言  |  RSS订阅  |  违规举报  |  鄂ICP备2020018471号