Last active
April 21, 2021 16:06
-
-
Save lucaswells/2087274957d9d97e1e207289877e5cb6 to your computer and use it in GitHub Desktop.
Upload local directory to Google Cloud Storage bucket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# =================================================== | |
# Upload Directory to GCP Cloud Storage | |
# --------------------------------------------------- | |
# | |
# ARGUMENTS | |
# ========= | |
# | |
# GCP project id : string : pos 1 | |
# The ID. Not the project name or project number | |
# | |
# Local directory to upload : string : pos 2 | |
# Absolute or relative path to local directory | |
# | |
# GCS storage bucket : string : pos 3 | |
# Just the name of the bucket, don't include gs:// | |
# | |
# =================================================== | |
echo "" | |
echo "GCP project id: $1" | |
echo "Local directory: $2" | |
echo "GCS bucket name: $3" | |
echo "" | |
read -p "Do you wish to continue? (y/n): " CONT | |
if [ "$CONT" = "y" ]; then | |
echo "" | |
echo "Setting project..." | |
gcloud config set project "$1" | |
echo "" | |
echo "Uploading..." | |
gsutil -m cp -R "$2" gs://"$3" | |
else | |
echo "exiting" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment