Last active
October 16, 2019 01:20
-
-
Save rajannpatel/63bbc6aada41e0534ae5d09a098d0be7 to your computer and use it in GitHub Desktop.
rsync to google cloud storage with gsutil in a short and simple bash script, which takes an array of local directories as the source
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
#!/usr/bin/env bash | |
bucket=name-of-your-bucket | |
dirs=( | |
~/relative/path | |
../relative/path2 | |
/absolute/path/ | |
/Volumes/Macintosh HD/full/absolute/path | |
) | |
for dir in ${dirs[@]} | |
do | |
path="$(cd "$(dirname "${dir}")"; pwd)/$(basename "${dir}")" | |
# absolute path solution: https://stackoverflow.com/a/31605674/3700104 | |
echo ${path} && gsutil -m rsync -e -r -d "${path}" "gs://${bucket}${path}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment