Last active
January 9, 2019 13:42
-
-
Save pirafrank/00529b9c07d79389847aec173bd74abf to your computer and use it in GitHub Desktop.
Backup and deploy to Amazon S3 static resources of my website (fpira.com)
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 | |
# crontab entry | |
# 0 0 * * * /bin/bash /home/francesco/fpiracom_static_backup.sh > /dev/null 2>&1 | |
# | |
# variables | |
# | |
ENV_PATH="/home/francesco/Code/awscli_lisa" # path to your virtualenv with awscli module | |
SOURCE_SYNC="/var/www/fpira.com_static" | |
S3_DEST="fpira-s3-media/fpira.com_static" | |
# committing to repo configured with git lfs | |
cd "$SOURCE_SYNC" | |
echo "pulling..." | |
git pull origin master | |
echo "backing up all the static files to the repo..." | |
git add . | |
sleep 1 | |
git commit -m 'commit' | |
sleep 1 | |
git push origin --all | |
# Sync to S3 bucket | |
source "$ENV_PATH""/bin/activate" | |
echo "Virtualenv is: ""$ENV_PATH""/bin/activate" | |
echo "Starting sync TO S3..." | |
aws s3 sync "$SOURCE_SYNC" "s3://""$S3_DEST" --exclude ".git/*" | |
# Greetings | |
echo " | |
All done! Bye... | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment