Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Backup and deploy to Amazon S3 static resources of my website (fpira.com)
#!/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
You can’t perform that action at this time.