#!/bin/sh
FILE_NAME=dotacai_`date +\%Y\%m\%d`.sql
ZIP_FILE_NAME=$FILE_NAME.gz
LOCAL_PATH=/home/azhibo/db_dump
REMOTE_PATH=/srv/db_dumps/backup
REMOTE_FILE=$REMOTE_PATH/$ZIP_FILE_NAME
SOURCE_FILE=$LOCAL_PATH/$FILE_NAME
ssh -t dotacai_db "sudo sh /root/scripts/dump_db_to_backup";
scp dotacai_db:$REMOTE_FILE $LOCAL_PATH
gunzip $LOCAL_PATH/$ZIP_FILE_NAME
mysql -uroot -p123456 -e "drop database if exists dota2;create database dota2 charset utf8;use dota2;source ${SOURCE_FILE};"
echo '导入完成'