f3rrix / s3sync-s3cmd

Automatically exported from code.google.com/p/s3sync-s3cmd
0 stars 0 forks source link

s3cmd, s3sync should return non-zero exit status on errors #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

It would be easier to use s3cmd and s3sync in shell scripts if they
returned non-zero exit status on errors.

1. Non existing key, s3cmd prints an error message but returns success:

[root@domU:~] s3cmd get <some bucket>:non-existent-key a
S3 command failed:
get_stream <some bucket> non-existent-key  #<File:0xb7846810>
With result 404 Not Found
[root@domU:~] echo $?
0

2. The same goes for s3cmd sync:

[root@domU:~] s3sync <some bucket>:DOES_NOT_EXIST /tmp
[root@domU:~] echo $?
0

3. if you don't have your keys set, an error message is printed, but the
command still returns success:

[root@domU:~] unset AWS_ACCESS_KEY_ID
[root@domU:~] s3cmd get <some bucket>:<some key> a
You didn't set up your environment variables; see README.txt
s3cmd [options] <command> [arg(s)]        version 1.0.6
  --help    -h        --verbose     -v     --dryrun    -n   
  --ssl     -s        --debug       -d     --progress

Commands:
s3cmd  listbuckets  [headers]
s3cmd  createbucket|deletebucket  <bucket>  [headers]
s3cmd  list  <bucket>[:prefix]  [max/page]  [delimiter]  [headers]
s3cmd  delete  <bucket>:key  [headers]
s3cmd  deleteall  <bucket>[:prefix]  [headers]
s3cmd  get|put  <bucket>:key  <file>  [headers]
[root@domU:~] echo $?
0

Original issue reported on code.google.com by ogrodnek on 22 Sep 2008 at 10:14

GoogleCodeExporter commented 9 years ago
Yes, please update this. We need to verify that our frequent s3sync cron job is 
successful. This appears to be an 
easy update.

Original comment by pdt...@gmail.com on 10 Jul 2009 at 3:48

GoogleCodeExporter commented 9 years ago
Indeed, I just noticed that this would be excellent to do automated backups. I 
thought of having a cron job like the following:

0 1 * * * SITE=example.com; s3cmd sync --exclude=cache /var/www/$SITE/ 
s3://$SITE || mail -s "Backup of $SITE to S3 FAILED" me@example.com --

But unfortunately there is no notification even after a failed backup, as s3cmd 
sync always returns 0 even on errors...

Original comment by pablo.en...@gmail.com on 2 Mar 2011 at 10:48

GoogleCodeExporter commented 9 years ago
Yes.

Just realized that s3cmd doesn't give out the correct return status codes and 
that makes it close to impossible to use it in shell scripts. (It's fairly 
common that an upload to s3 failes)

Original comment by tob...@bandpage.com on 24 Mar 2011 at 6:41

GoogleCodeExporter commented 9 years ago
Can anyone please fix the exit code issue, it is very difficult to track the 
status of file tranfers without this.

Original comment by svsnr2.r...@gmail.com on 5 Oct 2012 at 11:02

GoogleCodeExporter commented 9 years ago
+1 for non-zero return code on failed transfers. Just hit this problem as well.

Original comment by su...@longtailvideo.com on 14 Jan 2013 at 10:21

GoogleCodeExporter commented 9 years ago
FYI, seems like this project is abandoned?  We've moved on to use: 
https://github.com/aboisvert/s3cp which is a little more sane...

Original comment by ogrodnek on 14 Jan 2013 at 10:25