Created
September 3, 2013 06:39
-
-
Save netkiller/6420375 to your computer and use it in GitHub Desktop.
Revisions
-
netkiller created this gist
Sep 3, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #!/bin/bash ################################### # $Id: backup 381 2012-04-03 09:49:08Z netkiller $ # Author: [email protected] # Home: http://netkiller.github.com ################################### BACKUP_HOST="localhost" BACKUP_USER="root" BACKUP_PASS="" BACKUP_DIR=/opt/backup BACKUP_DBNAME="test neo" #Number of copies COPIES=7 #################################### MYSQLDUMP="mysqldump" #TIMEPOINT=$(date -u +%Y-%m-%d) TIMEPOINT=$(date -u +%Y-%m-%d.%H:%M:%S) MYSQLDUMP_OPTS="-h $BACKUP_HOST -u$BACKUP_USER -p$BACKUP_PASS" #################################### umask 0077 test ! -d "$BACKUP_DIR" && mkdir -p "$BACKUP_DIR" test ! -w $BACKUP_DIR && echo "Error: $BACKUP_DIR is un-writeable." && exit 0 for dbname in $BACKUP_DBNAME do test ! -d "$BACKUP_DIR/$dbname" && mkdir -p "$BACKUP_DIR/$dbname" $MYSQLDUMP $MYSQLDUMP_OPTS $dbname | gzip > $BACKUP_DIR/$dbname/$dbname.$TIMEPOINT.sql.gz done find $BACKUP_DIR -type f -mtime +$COPIES -delete