Hello, please sign in or register
You are here: Home

Copy and mysqldump files and extract

#!/bin/bash

# Copy over the zipped up files from Database server to Development Server

echo "Begin copy update of the dev server"
date

echo "Copying over from day number `date +\%w`"

time scp ftpuser@192.168.0.1:/path/on/remote/server/db_*.sql.`date +\%w`.gz /data/backup/

echo "Successfully copied over the fils"
echo "Extracting the contents of the compressed files"

time gunzip -f /data/backup/*

echo "Finished unzipping the files";

#find /data/backup/ -type f -print -exec mysql -uroot -p********** \< {} \;

#Return a list of databases

for file in `find /data/backup/ -type f`
do
   basename=`basename "$file"`
   pos=`expr index "$basename" .`
   pos=$[pos - 1]
   db_name=${basename:0:$pos}
   if [ $db_name != 'mysql' ]; then
       echo "Updating $db_name from $file"
       /opt/mysql/bin/mysql -uroot -ppasswd -e "CREATE DATABASE IF NOT EXISTS $db_name"
       /opt/mysql/bin/mysql $db_name -uroot -ppasswd < $file
       echo "Finished updating $db_name"
       echo "Removing the file $file"
   fi
   rm -rf $file
done


echo "COMPLETED"
date

Comments

0921maoqiuyun
cheap nba jerseys, http://www.nbajerseys.net/ jordan shoes, http:/...
Created 21/09/15
guoyanying
But the replica watches sentry reebok shoes knew abercrombie and fitch uk his
Created 07/10/15
1015maoqiuyun
coach outlet online, http://www.coachoutletonline-store.us.com/
Created 15/10/15
Title*
Comment

Prove you are not a robot

To prove you are not a robot, please type in the six character code you see in the picture below
Security confirmation codeI can't see this!
Contact
Name*
Email never shown*
Home Page

Author

Andrew Dodson
Since:Feb 2007

Comment | flag

Categories

Bookmark and Share