Skip to content

Instantly share code, notes, and snippets.

@codl
Created September 25, 2017 19:54
Show Gist options
  • Save codl/879b78bff86f480a1a1d06b4389a48e4 to your computer and use it in GitHub Desktop.
Save codl/879b78bff86f480a1a1d06b4389a48e4 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -eufo pipefail
SIZE=0
F=$(mktemp --tmpdir b2-bucket-size.json.XXXX)
b2 list-file-versions $1 > $F
while true; do
SIZE=$[$SIZE + $(jq -r '[.files[].contentLength] | add' $F)]
NEXT=$(jq -r '.nextFileName' $F)
NEXTID=$(jq -r '.nextFileId' $F)
[[ $NEXT == 'null' ]] && break
b2 list-file-versions $1 $NEXT $NEXTID > $F
done
echo $SIZE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment