Forked from stiucsib86/gist:ebff282a3989f9a24117
Last active
September 6, 2018 20:00
-
-
Save malkafly/578ec3accf6938780f91cf57350fc1f3 to your computer and use it in GitHub Desktop.
Backup MySQL dump to Azure Storage
This file contains hidden or 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/sh | |
mkdir /home/bitnami/backups/ | |
export BACKUP_FILE=/home/bitnami/backups/db-backup.sql.gz | |
export DATABASE_SCHEMA_NAME=--all-databases | |
export AZURE_CONTAINER=YOUR_VALUE_HERE | |
export AZURE_NAME=YOUR_VALUE_HERE | |
export AZURE_KEY=YOUR_VALUE_HERE | |
export AZURE_BLOB_NAME=db-production-$(date +%Y%m%d%H%M%S).sql.gz | |
/opt/bitnami/mysql/bin/mysqldump $DATABASE_SCHEMA_NAME > temp.sql | |
gzip temp.sql | |
rm -rf $BACKUP_FILE | |
mv temp.sql.gz $BACKUP_FILE | |
#azure storage blob -a $AZURE_NAME -k $AZURE_KEY upload --container $AZURE_CONTAINER -f $BACKUP_FILE -b $AZURE_BLOB_NAME | |
az storage blob upload -f $BACKUP_FILE -c $AZURE_CONTAINER -n $AZURE_BLOB_NAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sudo crontab -e
Cron:
0 1 * * * /usr/bin/sh /home/usuario/bkp.sh
(todos os dias a 1 da manhã)