Shopify/brigade — pull request #16 by aybabtme (2014-08-07 19:43:33+00:00)
Title: Failures to upload artifacts

I ran `brigade backup` earlier this week and noticed the artifacts weren't uploaded to S3 as they should. Looking at the logs:

```
msg = "failed to persist backup artifact"
error = "Your proposed upload exceeds the maximum allowed size"
file = "2014-08-05T22:02:05Z_source_list.json.gz"
```

Seems the list of keys was too large for a single PUT to S3. Incidentally, I've lost the file, since the backup tool deletes it's artifacts when it's done with them.

So this PR does two things:

1. Only delete artifacts if there was no error doing the full backup (list -> diff -> sync -> send artifacts to S3).
2. If S3 responds with a `too large` error, do a multipart upload.

### FAQ:

* __Why 1 GB parts?__: the max number of parts is 1024, minimum size of 5MB each. Since single PUT max size is 5GB, we will have at least 5 parts to upload if we need to do a multipart upload. 1GB is a large enough number to keep the link busy, and is good for files up to 1TB. Hopefully the size of our GZIP'd metadata will never be 1TB big.

r: @camilo @fbogsany @shuhaowu
cc: @Shopify/webscale