Created
February 2, 2023 12:26
-
-
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
This file contains hidden or 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
#!/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 |
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
To run above script: