Skip to content

Instantly share code, notes, and snippets.

@mudssrali
Created February 2, 2023 12:26
Show Gist options
  • Save mudssrali/d08820a490d04020c5430d73258d4450 to your computer and use it in GitHub Desktop.
Save mudssrali/d08820a490d04020c5430d73258d4450 to your computer and use it in GitHub Desktop.
Bash script to download a dir, zip it and upload to Google Cloud Storage using gsutil
#!/usr/bin/env bash
# make sure this bash script has executable permission, if doesn't have, run following command
# > $ chmod +x *.sh
gsutil - m cp - r "gs://[BUCKET_PATH]/$1". \
zip - r /root/ $1.zip $1 \
rm - rf $1 \
gsutil cp /root/ $1.zip gs://[BUCKET_PATH]/ \
rm -rf /root/$1.zip
@mudssrali
Copy link
Author

To run above script:

./upload.sh [DIR_NAME]

@mudssrali
Copy link
Author

I had to write zipped file to under /root/ because of insufficient space in /home/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment