Jump to content
ilbr22

Script backup baza de date mysql - BASH

Recommended Posts

Posted

#!/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

sursa: www[.]linux-tutorial[.]eu

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...