Created
October 11, 2018 10:44
-
-
Save hackedunit/23df4267df4b6cd6213a64d17988e2ba to your computer and use it in GitHub Desktop.
Gzip a directory and upload to Azure Blob storage
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 | |
# Requires azure-cli to be installed | |
source $HOME/.profile | |
echo "backing up media dir..." | |
tar -zcf /tmp/media.gz /var/www/app/shared/media | |
if [ $? == 0 ]; then | |
/usr/bin/az storage blob upload --name "media-$(date +%s).gz" --file /tmp/media.gz --container-name "fileuploads" --connection-string "DefaultEndpointsProtocol=https;AccountName=$AZURE_STORAGE_ACCOUNT;AccountKey=$AZURE_STORAGE_ACCESS_KEY;EndpointSuffix=core.windows.net;" | |
if [ $? == 0 ]; then | |
echo "success!" | |
rm /tmp/media.gz | |
else | |
>&2 echo "couldn't transfer media.gz to Azure" | |
fi | |
else | |
>&2 echo "couldn't gzip media dir" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment