Subversion Repositories My Stuff

Compare Revisions

Ignore whitespace Rev 30 → Rev 31

/trunk/Bash/mysql_data_backup.sh
0,0 → 1,41
#!/bin/bash
 
#####################################################################
# Script to make data copy from mysql
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# Author: Andrzej Kardaƛ
# License: GPLv3
# The full version of the licencse can be obtainted by visiting:
# http://www.gnu.org/licenses/gpl.html
#######################################################################
 
MYUSER=${1}
PASSWORD=${2}
BCKPATH=${3}
MYSQL="/usr/bin/mysql"
MYSQLDUMP="/usr/bin/mysqldump"
if [ -d ${BCKPATH} ]; then
echo "Path seems ok"
echo
else
echo "Can not find the provided path check script parameters"
echo
exit 1
fi
DATABASES="$(${MYSQL} -u ${MYUSER} -p${PASSWORD} -Bse 'show databases')"
for name in ${DATABASES}
do
FILE=${BCKPATH}/mysql-data-${name}-$(date +"%d_%m_%y").sql
echo "Creating backup of database ${name} to file ${FILE}"
if (${MYSQLDUMP} --skip-triggers --compact --no-create-info --disable-keys -u ${MYUSER} -p${PASSWORD} ${name} > ${FILE}) then
echo "Storing database ${name} in ${FILE} succesfull"
echo
else
echo "Storing database ${name} in ${FILE} failed"
echo
fi
done
Property changes:
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property