文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>MYSQL备份脚本

MYSQL备份脚本

时间:2008-04-13  来源:huzi1986

#!/bin/sh
# Name:mysqlbackup.sh
# PS:MySQL DataBase Backup,Use mysqlhotcopy script.
# Write by:i.Stone
# Last Modify:2007-11-15
#
# Define variables.
scriptsDir=`pwd`
dataDir=/var/lib/mysql/
tmpBackupDir=/tmp/tmpbackup/
backupDir=/home/mysql_back
mysqlUser=root
mysqlPWD=dayuweiwei
[email protected]
if [[ -e $tmpBackupDir ]]; then
  rm -rf $tmpBackupDir/*
else
  mkdir $tmpBackupDir
fi
if [[ ! -e $backupDir ]];then
mkdir $backupDir
fi

if [[ -s MySQLBackup.log ]]; then
  cat /dev/null >MySQLBackup.log
fi
for databases in `find $dataDir -type d | \
  sed -e "s/\/var\/lib\/mysql\///" | \
  sed -e "s/test//"`; do
  if [[ $databases == "" ]]; then
    continue
  else
    /usr/bin/mysqlhotcopy --user=$mysqlUser --password=$mysqlPWD -q "$databases" $tmpBackupDir
    dateTime=`date "+%Y.%m.%d %H:%M:%S"`
    echo "$dateTime Database:$databases backup success!" >>MySQLBackup.log
  fi
done
date=`date -I`
cd $tmpBackupDir
tar czf $backupDir/mysql-$date.tar.gz ./
if [[ -s MySQLBackup.log ]]; then
  cat MySQLBackup.log | mail -s "MySQL Backup" $eMail
fi
 
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载