Skip to content

Instantly share code, notes, and snippets.

@mikedemers
Created March 20, 2013 18:37
Show Gist options
  • Save mikedemers/5207268 to your computer and use it in GitHub Desktop.
Save mikedemers/5207268 to your computer and use it in GitHub Desktop.
Shell script that dumps a database and uses archiver.rb to send to an S3 bucket. I run this from cron.
#!/bin/bash
BUDIR="/home/mike/backup/db"
UN="username"
PW="password"
DB="database_name"
BUCKET="bucket-name"
ARCHIVER="/home/mike/backup/bin/archiver.rb"
MYDUMP="/usr/bin/mysqldump"
GZIP="/bin/gzip"
BUFILE="APPNAME-`date +'%Y%m%d-%H%M%S'`.sql.gz"
${MYDUMP} --opt --user="${UN}" --password="${PW}" ${DB} | ${GZIP} > ${BUDIR}/${BUFILE}
${ARCHIVER} "${BUCKET}" "${BUDIR}/${BUFILE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment