Skip to content

Instantly share code, notes, and snippets.

@DeCarvalhoBruno
Created May 9, 2015 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DeCarvalhoBruno/8609838e22c7210ad7a3 to your computer and use it in GitHub Desktop.
Save DeCarvalhoBruno/8609838e22c7210ad7a3 to your computer and use it in GitHub Desktop.
Uploading mysql dumps to dropbox
#!/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
@DeCarvalhoBruno
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment