Skip to content

Instantly share code, notes, and snippets.

@DrPaulBrewer
Last active January 16, 2020 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DrPaulBrewer/63b0288138b95173ba8687778d1bacb6 to your computer and use it in GitHub Desktop.
Save DrPaulBrewer/63b0288138b95173ba8687778d1bacb6 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
# Copyright 2020 Paul Brewer, Economic and Financial Technology Consulting LLC
# Open Source License: The MIT License, see https://opensource.org/licenses/MIT
# rsyncs (read-only) all files in all accessible Google Cloud Storage Buckets to ~/gb/<bucketname>/
# Important: This script can use many gigabytes of Google Cloud outgoing bandwidth even in a short period of time.
# All fees for Google bandwidth are the responsibility of the user running this software.
mkdir -p ~/gb
cd ~/gb
BUCKETLIST=$(gsutil ls gs://)
for b in $BUCKETLIST
do (
DEST=./$(echo $b | sed -e 's/gs://' | sed -e 's/\///g' )/
mkdir -p $DEST
echo $b $DEST
gsutil -m rsync -r $b $DEST
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment