最近总是收到一个备份脚本的失败邮件,脚本是之前同事写的,没有加入任何有调试信息,及有用的日志

于是去分析 ,脚本中有一条 aws s3 sync $srclocal  $dsts3 命令,然后根据这条命令的执行状态码判断成功与失败

失败后,会发送失败的提醒邮件,然后去s3界面去看,s3 sync备份任务又好像是的成功的,主要的核心的备份文件都是在的

难道是部分文件备份失败,于是加入调试信息,输出stderr信息及exit code,最后return code 为 2

最后,去查询了一下,aws cli相关的文档,AWS CLI Return Codes, 有一段说明如下:

These are the following return codes returned at the end of execution of a CLI command:

0 -- The service responded with an HTTP response status code of 200 and
there were no errors from either the CLI or the service the request was made to. 1 -- Limited to s3 commands, at least one or more s3 transfers failed for the command executed. 2 -- The meaning of this return code depends on the command being run.
The primary meaning is that the command entered on the command line failed to be parsed.
Parsing failures can be caused by, but are not limited to, missing any required subcommands
or arguments or using any unknown commands or arguments. Note that this return code meaning is applicable to all CLI commands. The other meaning is only applicable to s3 commands.
It can mean at least one or more files marked for transfer were skipped during the transfer process.
However, all other files marked for transfer were successfully transferred.
Files that are skipped during the transfer process include: files that do not exist,
files that are character special devices,block special device, FIFO's, or sockets, and files that the user cannot read from. 130 -- The process received a SIGINT (Ctrl-C). 255 -- Command failed. There were errors from either the CLI or the service the request was made to.

官方文档参考:https://docs.aws.amazon.com/cli/latest/topic/return-codes.html

对于2的返回码分析,加之输出的调试信息分析 ,发现用户对某一个文件,没有读的权限

[qq_5201351@localhost tmp]$ cat Project_s3sync_stderr.log
warning: Skipping file /backup/db-backup.20211108.tar. File/Directory is not readable.

解决方法:对于这个文件,给执行备份脚本的用户加上读权限即可~

另:在生产环境中,笔者还会遇到exit code 为1的情况,查询日志如下:

upload failed: ../../dir/.log.16 to s3://qq5201351/.log.16 [Errno 2] No such file or directory: '/dir/.log.16'

笔者检查了一下,其他文件是正常的,这种情况一般就是少数的文件传输失败

而且笔者这里的场景,很可能这个文件在当时是有变化的,如临时缓存文件完成后重命名了,所以找不到了

尊重别人的劳动成果 转载请务必注明出处:https://www.cnblogs.com/5201351/p/15523673.html

关于aws cli命令的exit/return code分析的更多相关文章

  1. AWS Switching to an IAM role (AWS CLI)

    一,引言 今天额外分享一篇 AWS 的技术内容,需要在 EC2 切换到跨账号 IAM 角色(AWS CLI).假设我们使用两个 AWS 账户,A账号,B账号.我们希望允许 A 账号用于 "i ...

  2. AWS CLI以及AWS S3 SYNC命令行使用

    1.到AWS的IAM创建用户,并且获取到访问密钥 ID 和私有访问密钥.下载密钥并保存. 2.到http://docs.amazonaws.cn/cli/latest/userguide/instal ...

  3. 报错,但不影响运行ERROR: JDWP Unable to get JNI 1.2 environment, jvm->GetEnv() return code = -2

    参考:http://blog.csdn.net/zxl0016/article/details/7327125 eclipse 3.4+jdk1.6 编译正常通过,运行debug模式时报错 ERROR ...

  4. Hive的Shell里hive> 执行操作时,出现FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask错误的解决办法(图文详解)

    不多说,直接上干货! 这个问题,得非 你的hive和hbase是不是同样都是CDH版本,还是一个是apache版本,一个是CDH版本. 问题详情 [kfk@bigdata-pro01 apache-h ...

  5. 为你的AliOS Things应用增加自定义cli命令

    摘要: 怎么才能在RTOS系统中,通过 串口shell控制LED的开关. 在日常嵌入式开发中,我们经常会用串口命令来使设备进入某种特定的状态,或执行某个特定的操作.如系统自检,模拟运行,或者进入手动模 ...

  6. golang常用库:cli命令行/应用程序生成工具-cobra使用

    golang常用库:cli命令行/应用程序生成工具-cobra使用 一.Cobra 介绍 我前面有一篇文章介绍了配置文件解析库 Viper 的使用,这篇介绍 Cobra 的使用,你猜的没错,这 2 个 ...

  7. Hive创建表格报【Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException】引发的血案

    在成功启动Hive之后感慨这次终于没有出现Bug了,满怀信心地打了长长的创建表格的命令,结果现实再一次给了我一棒,报了以下的错误Error, return code 1 from org.apache ...

  8. [Notes] AWS Automation using script and AWS CLI

    (c) 2014 Amazon Web Services, Inc. and its afflialtes, All rights reserved. The content in this file ...

  9. AWS CLI 中使用S3存储

    登录 通过控制面板, 在S3管理器中创建一个新的bucket 所有AWS服务 -> 安全&身份 -> IAM -> 组, 创建一个新的组, 例如 "s3-user& ...

随机推荐

  1. 用kubeadm简单部署k8s

    一.环境准备 1.三台CentOS6.7虚拟机 master:192.168.0.54 注意:主节点最好是2颗cpu,否则在k8s控制平面初始化的时候会报错: node1:192.168.0.68 n ...

  2. Redis系列4:高可用之Sentinel(哨兵模式)

    Redis系列1:深刻理解高性能Redis的本质 Redis系列2:数据持久化提高可用性 Redis系列3:高可用之主从架构 1 背景 从第三篇 Redis系列3:高可用之主从架构 ,我们知道,为Re ...

  3. 项目经验记录丨Modbus转EtherNET/IP协议转换应用

    使用电脑通过软件来进行模拟 EtherNET/IP主站连接Mdodbus从站设备的项目记录.使用软件为EIPScan 模拟主站,通过Modbus转EtherNET/IP网关连接Modbus Slave ...

  4. Java面试题(六)--Redis

    1 Redis基础篇 1.简单介绍一下Redis优点和缺点? 优点: 1.本质上是一个 Key-Value 类型的内存数据库,很像memcached 2.整个数据库统统加载在内存当中进行操作,定期通过 ...

  5. 8. 利用Ansible快速构建MGR | 深入浅出MGR

    GreatSQL社区原创内容未经授权不得随意使用,转载请联系小编并注明来源. 目录 1. 安装ansbile 2. 配置ansible 3. 建立ssh信任 4. 测试ansible 5. 使用ans ...

  6. Redis 01 概述

    参考源 https://www.bilibili.com/video/BV1S54y1R7SB?spm_id_from=333.999.0.0 版本 本文章基于 Redis 6.2.6 简介 NoSQ ...

  7. Excelize 发布 2.6.0 版本,功能强大的 Excel 文档基础库

    Excelize 是 Go 语言编写的用于操作 Office Excel 文档基础库,基于 ECMA-376,ISO/IEC 29500 国际标准.可以使用它来读取.写入由 Microsoft Exc ...

  8. React报错之Rendered more hooks than during the previous render

    正文从这开始~ 总览 当我们有条件地调用一个钩子或在所有钩子运行之前提前返回时,会产生"Rendered more hooks than during the previous render ...

  9. 在Boss直聘上投简历时,怎样保证有新消息时能及时收到

    最近在Boss直聘上投简历,偶尔会有HR给我发消息,不想在电脑上错过这些消息,但我又不能时时刻刻盯着这个页,怎么办呢? 这时,我想起来,之前做过的Chrome插件,如果检测到Boss直聘上新消息数大于 ...

  10. Swift中的Result 类型的简单介绍

    Swift 5引入了一个新的Result类型, 它使用枚举来处理异步函数的结果. 苹果文档对该类型的描述: A value that represents either a success or a ...