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

于是去分析 ,脚本中有一条 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. 在docker容器中如何自动生成配置文件(以nginx配置为例)

    应用场景类似于多个域名要起多个容器,有些参数有些域名需要,有些域名不需要,或者参数的值不太一样,需要去对应的配置文件修改,不太灵活,如果通过变量的方式直接定义在Dockerfile文件中,需要哪些参数 ...

  2. 基于二进制安装Cloudera Manager集群

    一.环境准备 参考链接:https://www.cnblogs.com/zhangzhide/p/11108472.html 二.安装jdk(三台主机都要做) 下载jdk安装包并解压:tar xvf ...

  3. vscode无法调试python2.7版本

    概述 好久没有用python2.7版本了,最近有个老的脚本要优化,但是发现vscode无法对脚本调试,特此记录下解决方法. 本地安装有python2和python3,开发过程中,vscode可以随时调 ...

  4. Mybatis的使用(1)

    1:新建maven项目,file->project->maven 2:在建好的maven项目中,打开pom.xml文件,加入mybatis所需要的依赖: <!-- mybatis核心 ...

  5. 基于ABP和Magicodes实现Excel导出操作

      前端使用的vue-element-admin框架,后端使用ABP框架,Excel导出使用的Magicodes.IE.Excel.Abp库.Excel导入和导出操作几乎一样,不再介绍.文本主要介绍E ...

  6. 用好JAVA中的函数式接口,轻松从通用代码框架中剥离掉业务定制逻辑

    大家好,又见面了. 今天我们一起聊一聊JAVA中的函数式接口.那我们首先要知道啥是函数式接口.它和JAVA中普通的接口有啥区别?其实函数式接口也是一个Interface类,是一种比较特殊的接口类,这个 ...

  7. MyBatis ognl.NoSuchPropertyException 或者 Invalid bound statement (not found)

    描述 SpringBoot + Mybatis-plus 项目,运行时出现如下错误: ognl.NoSuchPropertyException:没有对应属性异常 Invalid bound state ...

  8. Z-Libary最新地址.Z-Libary无法登录解决方案

    Z-Library.世界上最大的数字图书馆. 如果你知道了一本书的书名,那在Z-Library上基本上都可以找到进行下载, Z-Library 有很多入口,分为官方和民间镜像.官方自己做了个跳转站点, ...

  9. 057_末晨曦Vue技术_处理边界情况之强制更新($forceUpdate)与通过 v-once 创建低开销的静态组件

    强制更新($forceUpdate) 点击打开视频讲解更加详细 在vue中,如果data中有基本数据类型变量:age,修改他,页面会自动更新. 但如果data中的变量为数组或对象(引用数据类型),我们 ...

  10. Express 使用 Cookie

    在使用 Cookie 之前,需要给 Express 加载中间件,cookie-parser: npm i cookie-parser Express 使用中间件: import express fro ...