查看完整版本: mysql 備份腳本

ihao 2012-8-11 22:10

mysql 備份腳本

mysql 備份腳本
#!/bin/sh
#-----------------------------------------------#
#This is a  free GNU GPL version 3.0 or abover
#Copyright (C) 2008 06 05
#mysql_backup Dedicated copyright
#-----------------------------------------------#
echo -e [`date +"%Y-%m-%d %H:%M:%S"`] start
#system time
time=`date +"%y-%m-%d"`
#host IP
host="127.0.0.1"
#database backup user
user="root"
#database password
passwd="mysql45"
#Create a backup directory
mkdir -p /opt/backup/"$time"
#list database name
all_database=`/opt/app/mysql5/bin/mysql -u "$user" -h "$host" -p"$passwd" -Bse 'show databases'`
#in the table from the database backup
for i in $all_database
do
/opt/app/mysql5/bin/mysqlhotcopy -u "$user" -h "$host" -p"$passwd" --addtodest "$all_database" /opt/backup/"$time"/
done
echo -e [`date +"%Y-%m-%d %H:%M:%S"`]  end
exit 0
頁: [1]
查看完整版本: mysql 備份腳本