Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » 7. Operating System » Script Mirroring Database

Script Mirroring Database

#! /bin/bash

TIMESTAMP=$(date +”%F”)
BACKUP_DIR=”/home/database_only/backup/$TIMESTAMP/mysql”
MYSQL_USER=”dimas”
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD=”prbn10prbn10″
HOST=192.168.1.100
MYSQLDUMP=/usr/bin/mysqldump

echo $BACKUP_DIR;
echo $TIMESTAMP;

cd $BACKUP_DIR
gunzip -f 0328*.gz;gunzip -f 0324*.gz;gunzip -f 0335*.gz;gunzip -f db_0323*.gz
ls 0328* > dbPemda.txt;ls 0324* >> dbPemda.txt;ls 0335* >> dbPemda.txt;ls db_0323* >> dbPemda.txt
dbPemda=$BACKUP_DIR/dbPemda.txt
echo $dbPemda;

while read line
do
echo “$line”
$MYSQL -u $MYSQL_USER -p$MYSQL_PASSWORD -h $HOST < $line;
done < $dbPemda

Filed under: 7. Operating System

Leave a Reply

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>