Search
j0ke.net Open Build Service
>
Projects
>
server:backup
>
automysqlbackup
> multimysqlbackup.sh
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File multimysqlbackup.sh of Package automysqlbackup (Revision 20)
Currently displaying revision
20
,
show latest
#!/bin/bash # # Name: multimysqlbackup # Summary: wrapper for automysqlbackup to backup multiple hosts # Version: 0.2 # Author: Carsten Schoene <cs@linux-administrator.com> # Last change: 21-10-2011 # ############################################################################### # path to host,db definitions CONFPATH="/etc/multimysqlbackup.conf" # path to mysql backup script AUTOMYSQLBACKUP="/usr/sbin/automysqlbackup" # lock each job LOCKJOB=1 # enable plesk detection AUTOPLESKBACKUP=1 # disable output on skipped configs SILENTERROR=1 ############################################################################### if [ -s "${CONFPATH}" ] ; then export MAILADDR for LINE in `cat ${CONFPATH} | grep -v ^# | grep -v ^$ | sed -e s@" "@"%20%"@g` ; do # format: host;user;password;databases_separated_by_spaces;databases_to_exclude_separated_by_spaces;tables_to_exclude export DBHOST=`echo ${LINE} | awk -F\; '{print $1}' | awk -F: '{print $1}'` export DBPORT=`echo ${LINE} | awk -F\; '{print $1}' | awk -F: '{print $2}'` export USERNAME=`echo ${LINE} | awk -F\; '{print $2}'` export PASSWORD=`echo ${LINE} | awk -F\; '{print $3}'` export DBNAMES=`echo ${LINE} | awk -F\; '{print $4}'|sed -e s@"%20%"@" "@g` export DBEXCLUDE=`echo ${LINE} | awk -F\; '{print $5}'|sed -e s@"%20%"@" "@g` export TABLEEXCLUDE=`echo ${LINE} | awk -F\; '{print $6}'|sed -e s@"%20%"@" "@g` if [ ! -f /var/lock/${DBHOST}.lock ] && [ "${LOCKJOB}" == "1" ] ; then touch /var/lock/${DBHOST}.lock ${AUTOMYSQLBACKUP} rm -f /var/lock/${DBHOST}.lock elif [ "${LOCKJOB}" == "0" ] ; then ${AUTOMYSQLBACKUP} else echo "LOCKJOB is enabled and /var/lock/${DBHOST}.lock file was found, please check! Script skips backup for host: ${DBHOST}" exit 2 fi done else if [ "${SILENTERROR}" == "0" ] ; then echo "Config file not found: ${CONFPATH} (skipping)" fi fi if [ "${AUTOPLESKBACKUP}" == "1" ] ; then # plesk autodetection if [ -s /usr/local/psa/version ] && [ -s /etc/psa/.psa.shadow ] ; then export DBHOST="localhost" export DBPORT="3306" export USERNAME="admin" export PASSWORD=`cat /etc/psa/.psa.shadow` export DBNAMES="all" export DBEXCLUDE="" export TABLEEXCLUDE="" if [ ! -f /var/lock/${DBHOST}.lock ] && [ "${LOCKJOB}" == "1" ] ; then touch /var/lock/${DBHOST}.lock ${AUTOMYSQLBACKUP} rm -f /var/lock/${DBHOST}.lock elif [ "${LOCKJOB}" == "0" ] ; then ${AUTOMYSQLBACKUP} else echo "LOCKJOB is enabled and /var/lock/${DBHOST}.lock file was found, please check! Script skips backup for host: ${DBHOST}" exit 3 fi else if [ "${SILENTERROR}" == "0" ] ; then echo "Plesk configuration not found: /usr/local/psa/version & /etc/psa/.psa.shadow (skipping)" fi fi fi