From db0d4679774c9f64a1d39aee40b2aefbbcb782ef Mon Sep 17 00:00:00 2001 From: Tomasz Klim Date: Sun, 12 Jan 2020 16:15:41 +0100 Subject: [PATCH] support for google cloud storage --- cron/daily.sh | 1 + internal/gs.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 internal/gs.sh diff --git a/cron/daily.sh b/cron/daily.sh index f2cb984..ee923ce 100755 --- a/cron/daily.sh +++ b/cron/daily.sh @@ -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 diff --git a/internal/gs.sh b/internal/gs.sh new file mode 100755 index 0000000..de276e7 --- /dev/null +++ b/internal/gs.sh @@ -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