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

于是去分析 ,脚本中有一条 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. 移动web开发01

    pc端的支持情况.IE9以下的版本就会全军覆没.移动端就不会出现版本支持问题. 因为第一个孩子是p,但是他又是在span里面选,所以根本选不出来,报错.改成第二个孩子才可以选出来. 这样就可以选出sp ...

  2. 当我们进行性能优化,我们在优化什么(LightHouse优化实操)

    好的互联网产品不仅仅在功能上要高人一筹,在性能层面也需要出类拔萃,否则金玉其外败絮其中,页面是美轮美奂了,结果首屏半天加载不出来,难免让用户乘兴而来,败兴而归. 幸运的是,前端的性能优化有诸多有迹可循 ...

  3. Vue 基本列表 && 数据过滤与排序

    1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="UTF-8" /> 5 & ...

  4. beego下让swagger按照更新了controllers的接口信息自动更新commentsRouter_controllers.go

    beego下让swagger按照更新了controllers的接口信息自动更新commentsRouter_controllers.go (1)在beego环境中,当更新了controllers目录下 ...

  5. BootStrap详解

    1. bootstrap的安装和使用 官网: https://getbootstrap.com/ 中文网: https://www.bootcss.com/ 菜鸟驿站教程网: https://www. ...

  6. 前端须知的 Cookie 知识

    文章已收录到我的 GitHub 中,欢迎 star cookie 是什么和使用场景 cookie 是服务器端保存在浏览器的一小段文本信息,浏览器每次向服务器端发出请求,都会附带上这段信息(不是所有都带 ...

  7. 你必须学UML之理论篇

    1.前言 对于当前社会背景下从事软件开发的工作者而言,"写代码"实际上并不是唯一的工作.特别在一些中小型的企业当中,这些企业往往对于开发者的要求,不单单停留在写代码完成相应功能上, ...

  8. Knative部署应用以及应用的更新、应用的分流(二)

    1. 应用的更新 1.1 更新hello-example应用 1.更新应用的环境变量 可通过命令行的方式亦可以通过读取配置文件的方式,这里主要来看命令行的方式 [root@kn-server-mast ...

  9. 第五章 部署master主控节点

    一.部署etcd集群 1.1 集群规划 主机名 角色 IP hdss7-12 leader 10.4.7.12 hdss7-21 follow 10.4.7.21 hdss7-22 follow 10 ...

  10. Android开发2021.3.9日【模拟器路径】【外观字体】【简单快捷键】

    一. 1.模拟器存储路径 D:\Android\SDK\platforms(在本人的dell上) 2.使用软件 Android Studio4.2 3.注意事项 (1)修改JDK的路径为自己下载的JD ...