2015年3月12日 星期四

5day_mysql.sh

#!/bin/sh
# -----------------------------
#/root/.my.cnf
#db_user="root"
#db_passwd=""
#db_host="localhost"
# the directory for story your backup file.
dir1="/home/lia/wcjh/d/"
dir2="/home/lia/wcjh/m/"
dir3="/home/lia/wcjh/y/"
dir4="/var/lib/mysql/"
dir5="/var/www/html/wcjh/data/"
# date format for backup file (yyyy-mm-dd)
time1="$(date +"%d")"
time2="$(date +"%Y%m%d")"
# mysql, mysqldump and some other bin's path
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
MKDIR="$(which mkdir)"
RM="$(which rm)"
MV="$(which mv)"
GZIP="$(which gzip)"
TAR="$(which tar)"
#DUMP="$(which dump)"
# check the directory for store backup is writeable
test ! -w $backup_dir && echo "Error: $backup_dir is un-writeable." && exit 0
##################################################################
#mysqldump_s1="$($MYSQLDUMP -uroot -p'' wcjh > "$dir1""wcjh.sql")"
#done
#$mysqldump_s1
#sleep 1
################################################################
#tar_s1="$($TAR zcvf "$dir1""mysql.tar.gz" "$dir4")"
#done
#$tar_s1
##################################################################
tar_s3="$($TAR zcvf "$dir3$time2""wcjh.tar.gz" "$dir1""wcjh.sql")"
#done
$tar_s3
##################################################################

沒有留言:

張貼留言