Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mysqlbackup [2014/10/26 01:52] (current)
Line 1: Line 1:
 +== MYSQL DB backup script ==
 +
 +<​code>​
 +
 +#!/bin/sh
 +
 +#
 +# db_backup.sh
 +# Shell script to backup mysql databases
 +#
 +# -=*=- -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-
 +# this is the only user configurable section
 +
 +USER=root
 +PASS=Secr@t
 +EMAIL=youremail@yahoo.com
 +HOST=localhost
 +DBNAME=comp
 +TABLES="​ids users computers versions"​
 +
 +DEBUG=1
 +DESTPATH=backup
 +
 +# please do not modify below this
 +# -=*=- -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-  -=*=-
 +
 +TIMESTAMP=`date +%m%d%Y`
 +LOGFILE=db_backup_${TIMESTAMP}\.log
 +DESTFILE=${DBNAME}_backup.sql_$TIMESTAMP
 +
 +if [ $DEBUG -eq 1 ]; then
 +    echo LOGFILE=$LOGFILE
 +    echo USER=$USER
 +    echo PASSWORD=$PASS
 +    echo DBNAME=$DBNAME
 +    echo TABLES=$TABLES
 +    echo DESTPATH=$DESTPATH
 +    echo DESTFILE=$DESTFILEfi
 +OPTIONS="​--complete-insert"​CMD="​mysqldump --user ${USER} --password ${PASS} --hostname ${HOST} $OPTIONS ${DBNAME} > ${DESTFILE}"​
 +echo ${CMD}
 +# uncomment
 +`${CMD}`
 +# move the current file to dest folder/file
 +CMD="​mv ${DESTFILE} ${DESTPATH}"​
 +echo ${CMD}
 +`${CMD}`
 +</​code>​
 +
 +----
 +
 +  * [[imaging|Back to Imaging/​Sysadmin]]
  
mysqlbackup.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0