Articles Comments

{ Berbagi, Menulis, Dan Mengajar } Ilmu… » 7. Operating System » Script Bekap DataBase

Script Bekap DataBase

root@Main-Ras-Server:~# crontab -l
# m h  dom mon dow   command
*/5 * * * * /usr/sbin/ntpdate id.pool.ntp.org  > /dev/null
#*/1 * * * * /etc/init.d/mysql restart
00 00 * * * /bin/sh /home/bekap_data/dbbackup.sh > /dev/null
@hourly /usr/bin/php /home/arif/noc.php > /dev/null

root@Main-Ras-Server:~# cat  /home/bekap_data/dbbackup.sh
#!/bin/bash
tgl=`date “+%d%m%Y”`;
mkdir /home/bekap_data/db/$tgl
sqldir=/home/bekap_data/db/$tgl;
dbhost=localhost
user=root
pass=’rahasiakita’
database=” information_schema forumDB kvaweb mysql

pajak ptpn11_map ptpn11wp ptpn11wp_old ptpn2010 revitalisasi2 t89607_eproc

t89607_ptpn t89607_sipgut webptpn11 aruskas forumDB hutangpiutang”
for db in $database;
do
v_name=$db”_”$tgl.sql;
mysqldump -u$user -h$dbhost -p$pass $db –skip-lock-tables –force > $sqldir/$v_name;
done
exit 0

End Script

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>