MYSQL DB backup script
#!/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}`

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