Skip to content

Commit

Permalink
support for google cloud storage
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszklim committed Jan 12, 2020
1 parent 1618cd8 commit db0d467
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions cron/daily.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ list="/var/cache/polynimbus/inventory/storage.list"
echo "### BEGIN `date`" >$log
/opt/polynimbus-backup/internal/s3.sh $list >>$log
/opt/polynimbus-backup/internal/b2.sh $list >>$log
/opt/polynimbus-backup/internal/gs.sh $list >>$log
/opt/polynimbus-backup/internal/azure.sh $list >>$log
/opt/polynimbus-backup/internal/linode.sh $list >>$log
echo "### END `date`" >>$log
28 changes: 28 additions & 0 deletions internal/gs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

list=$1

if [ "`which gcloud 2>/dev/null`" = "" ] && [ -f /root/google-cloud-sdk/path.bash.inc ]; then
. /root/google-cloud-sdk/path.bash.inc
fi

if [ "`which gcloud 2>/dev/null`" = "" ] || [ "`which gsutil 2>/dev/null`" = "" ]; then
echo "### skipping Google Storage (client software not found)"
exit 0
fi


buckets=`grep ^google $list |grep ' gs ' |awk '{ print $2 ":" $5 }'`
for entry in $buckets; do

account="${entry%:*}"
bucket="${entry##*:}"

path="/srv/polynimbus/gs/$account-$bucket"
if [ ! -d $path ]; then
mkdir -p -m 0700 $path
fi

echo "### syncing gs://$bucket"
gsutil rsync -r gs://$bucket $path
done

0 comments on commit db0d467

Please sign in to comment.