Last active
October 16, 2022 21:17
-
-
Save yazanmonshed/a1b49cf89b9625cadee48ed44a81d190 to your computer and use it in GitHub Desktop.
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 | |
# Notes | |
# *** need to export GCP Service account insdie the script | |
# pull data from S3 to local | |
DIR="/path/to/" | |
DATE=`date +%Y-%m-%d` | |
if [ ! -d $DIR ]; then | |
echo "$DIR not found...creating..." | |
mkdir -p ${DIR} | |
fi | |
echo "download files from s3..." | |
sleep 3 | |
aws s3 cp s3://path/to/ ${DIR} --exclude "*" --include "*${DATE}*" --recursive | |
if [ $? = 0 ]; then | |
echo "pull files completed succesfully" | |
else | |
echo "failed to pull files!" | |
exit 1 | |
echo "store unzip files.." | |
sleep 3 | |
STORE="/path/to/" | |
if [ ! -d $STORE ]; then | |
echo "$STORE not found...creating..." | |
mkdir -p ${STORE} | |
fi | |
echo "unzip all files..." | |
sleep 3 | |
cd ${DIR} && *.zip -d ${STORE} | |
echo "upload files to google storage.." | |
sleep 3 | |
gsutil cp "${STORE}/*.csv" gs://path/to/ | |
echo "cleanup files..." | |
find $DIR/*.csv.zip -exec rm {} \; | |
find $STORE/*.csv -exec rm {} \; | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment