Created
May 9, 2015 07:34
-
-
Save DeCarvalhoBruno/8609838e22c7210ad7a3 to your computer and use it in GitHub Desktop.
Uploading mysql dumps to dropbox
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 | |
# Creates a dump of a database and stores it in our Dropbox folder | |
#Grabbing today's date by executing the /bin/date command | |
FILENAME=`/bin/date +%Y_%m_%d` | |
#If a filename suffix was passed as a parameter, we add it to our filename | |
if [ -n "$1" ]; then | |
FILENAME+="_$1" | |
fi | |
#Storing the dump temporarily in the /tmp folder | |
mysqldump -u MyUser -pMyPassword MyDatabase | gzip -9 > /tmp/$FILENAME.sql.gz | |
#Using dropbox_uploader for the upload | |
/home/user/dropbox_uploader.sh upload /tmp/$FILENAME.sql.gz /DropboxFolderIfNeeded/$FILENAME.sql.gz | |
#Deleting the tmp file when we're done. | |
rm /tmp/$FILENAME.sql.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://goo.gl/sENEBr