Skip to content

Instantly share code, notes, and snippets.

@chorrell
Created October 25, 2011 01:38
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 chorrell/1311060 to your computer and use it in GitHub Desktop.
Save chorrell/1311060 to your computer and use it in GitHub Desktop.
#!/bin/bash
DBPATH=/home/hybrid/mysql_backups
MYSQLDMP=/opt/local/bin/mysqldump
FIND=/opt/local/bin/find
DATE=`date "+%Y-%m-%d"`
$MYSQLDMP --opt --skip-add-locks --user=hybrid_dbuser --password= xxxxxx --default-character-set=utf8 hybrid_forumdb | gzip > ${DBPATH}/hybrid_forumdb-${DATE}.gz
chown hybrid:hybrid ${DBPATH}/hybrid_forumdb-${DATE}.gz
# Deletes old backups
for DIR in `ls -1 $DBPATH`
do
$FIND ${DBPATH}/${DIR}/*.gz -mtime +14 -delete
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment