Subversion Repositories My Stuff

Compare Revisions

Ignore whitespace Rev 6 → Rev 7

/trunk/Bash/mysql_backup.sh
0,0 → 1,42
#!/bin/sh
 
#####################################################################
# Script to beckup MySQL databases to separate files
# 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-${name}-$(date +"%d_%m_%y").sql
echo "Creating backup of database ${name} to file ${FILE}"
if (${MYSQLDUMP} -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
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property