#!/bin/ksh
# Author : Jabir Ahmed
# Date : 26 Feb 08
# Purpose : To backup only a specified number of tables with data from the database
# Email : jabirahmed@yahoo.com
username='root';
password='xxxxx';
hostname='localhost';
command='mysqldump';
database='mysql';
dump_file='database_dump.dbh';
echo show tables|mysql -u $username -p$password -h $hostname $database > /tmp/$$.txt
if [ -e $dump_file ]
then
rm -rf $dump_file
fi
while read TABLENAME
do
echo -n "Backing up table " $TABLENAME
for i in user db func user
do
if [ "x$TABLENAME" == "x$i" ]
then
backup=1;
fi
done
if [ backup -eq 0 ]
then
echo "[ STRUCUTE ]"
$command $database -u $username -p$password -h $hostname $i -d >>$dump_file
else
echo '[ DATA ]';
$command $database -u $username -p$password -h $hostname $i >>$dump_file
fi
backup=0
done < /tmp/$$.txt
echo 'Done'
rm -rf tables.txt
exit;
1 comment:
if [ backup -eq 0 ] unary operator expected
there is no need of -eq
if [ "$backup" = "0" ]
try this
Post a Comment