Script
====
MYSQL_USER="root"
MYSQL_PASSWORD="xxxx"
DATABASE_NAME="c1"
echo "Restoring File:$1";
echo "Start Time:$(date)"
(
#echo "SET AUTOCOMMIT=0;"
echo "SET UNIQUE_CHECKS=0;"
echo "SET FOREIGN_KEY_CHECKS=0;"
cat "$1"
echo "SET FOREIGN_KEY_CHECKS=1;"
echo "SET UNIQUE_CHECKS=1;"
#echo "SET AUTOCOMMIT=1;"
#echo "COMMIT;"
) | mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$DATABASE_NAME"
echo "Start Time:$(date)"
How to Run
========
a)
Save above script in a file eg:sqlbackup.sql
b)
run the script with backup file name
#./restorescript.sh sqlbackup.sql
Output
=====
#./restorescript.sh sqlbackup.sql
Restoring File:convirt_ee-20121225
Start Time:Thu Jan 3 16:05:21 IST 2013
End Time:Thu Jan 3 16:50:21 IST 2013
====
MYSQL_USER="root"
MYSQL_PASSWORD="xxxx"
DATABASE_NAME="c1"
echo "Restoring File:$1";
echo "Start Time:$(date)"
(
#echo "SET AUTOCOMMIT=0;"
echo "SET UNIQUE_CHECKS=0;"
echo "SET FOREIGN_KEY_CHECKS=0;"
cat "$1"
echo "SET FOREIGN_KEY_CHECKS=1;"
echo "SET UNIQUE_CHECKS=1;"
#echo "SET AUTOCOMMIT=1;"
#echo "COMMIT;"
) | mysql -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" "$DATABASE_NAME"
echo "Start Time:$(date)"
How to Run
========
a)
Save above script in a file eg:sqlbackup.sql
b)
run the script with backup file name
#./restorescript.sh sqlbackup.sql
Output
=====
#./restorescript.sh sqlbackup.sql
Restoring File:convirt_ee-20121225
Start Time:Thu Jan 3 16:05:21 IST 2013
End Time:Thu Jan 3 16:50:21 IST 2013
No comments:
Post a Comment