Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » 7. Operating System » Script Backup Databases

Script Backup Databases

#!/bin/bash
tgl=`date “+%d%m%Y”`;
#mkdir /home/backup/program/$tgl
#mkdir /home/backup/sqldata/$tgl
#sqldir=/home/backup/sqldata/$tgl;
directory=”database”
MYSQL=/usr/bin/mysql
MYSQL_USER=”backup”
MYSQL_PASSWORD=”okedeh”
MYSQLDUMP=/usr/bin/mysqldump

databases=`$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD -e “SHOW DATABASES;” | grep -Ev “(Database|information_schema|performance_schema|test|db_dispenda|dbFakturIKC|dbHotelBjPerdana|dbHotelPasuruan|dbHotelSemeru|dbHotelTransit|dbHotelWismaKarya)”`

for folder in $directory;
do
v_name=$databases$tgl;
#tar -zcPf /home/backup/program/$tgl/$v_name.tar /home/$folder/
$MYSQL -u$MYSQL_USER -p$MYSQL_PASSWORD $databases < $v_name
done

#for db in $databases;
#do
#$MYSQLDUMP –force –opt –single-transaction –user=$MYSQL_USER -p$MYSQL_PASSWORD –databases $db | gzip > “$sqldir/$db.gz”
#done

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>