Single Blog

MYSQL Database Restoration in Linux

Please run below command that from where you want to take database to restore:

/usr/bin/mysqldump –user=proftpd –password=proftpd –opt –skip-lock-tables –single-transaction –default-character-set=binary –databases mds > MDS_Dump.sql

Note:- If we know the root password of the mysql, then use that credentials, after that zip MDS_DUMP.sql file and tranfer it into destination server.

To restore Please use below script:-
—————————
#!/bin/bash
#
# Script for restoring Database database.
# Modified by Sravan Kumar E
#

echo “Restoration staDatabaseed at: `date`” >> /tmp/restore.log
FILENAME=`date +%d-%b-%Y`
if [ -f /tmp/Database_Dump_?????????${FILENAME}.sql.gz ]
then
gunzip -d /tmp/Database_Dump_?????????${FILENAME}.sql.gz
mysqladmin –user=root –password=******** -f drop Database3 >> /tmp/restore.log 2>>/tmp/restore.log
RESTORE_FILE=`echo /tmp/Database_Dump_?????????${FILENAME}.sql`
echo “ImpoDatabaseing the data from ${RESTORE_FILE}” >> /tmp/restore.log
mysql –user=root –password=c1b8rn8t < ${RESTORE_FILE} gzip /tmp/Database_Dump_?????????${FILENAME}.sql rm -f /tmp/Database_Dump_?????????${FILENAME}.sql echo "Restoration completed at: `date`" >> /tmp/restore.log

else
echo “Restore Failed because of non availability of proper file” >> /tmp/restore.log
fi
—————————–

Comments (0)

Post a Comment