Jump to content

Script backup baza de date MySQL


polarson # ROMANIA

Recommended Posts

Un mic script bash pentru backup la bazele de date MySQL:

#!/bin/sh

# Backup Baze de date MySQL

b_dir="/usr/BACKUP/"
log_dir="/var/log/backup/"
MySQL_db_dir="/usr/local/mysql/var/"
MySQK_bk_user="userul de backup"
MySQL_bk_pw="Parola pentru userul de backup"

mkdir $b_dir`date +"%d%b%y"`
mkdir $b_dir`date +"%d%b%y"`/mysql/

# MySQL
for i in `ls $MySQL_db_dir | sed -e 's/\///'` ; do
if [ -d $MySQL_db_dir$i ] ; then
cd $b_dir`date +"%d%b%y"`/mysql/
/usr/bin/mysqldump $i -u $MySQL_bk_user -p"$MySQL_bk_pw" > $i-`date +"%d%b%y"`.sql
tar cjf $i-`date +"%d%b%y"`.sql.tar.bz2 $i-`date +"%d%b%y"`.sql
rm -rf $i-`date +"%d%b%y"`.sql
fi
done

DOWNLOAD SCRIPT

Job done. Enjoy!

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...