当前仓库属于暂停状态,部分功能使用受限,详情请查阅 仓库状态说明
1 Star 0 Fork 23

泽北风/lnmp
暂停

forked from Hailiang/lnmp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
db_backup_import.sh 1.63 KB
一键复制 编辑 原始数据 按行查看 历史
Hailiang 提交于 2017-10-26 11:34 . . lnmp_v1.1
#!/bin/bash
. include/common.sh
echo -e "$GREEN"
clear
echo -e "${GREEN}
#####################################################################
# LNMP is a bash script for the installation of Nginx + PHP + MySQL.#
# Author Hehl <[email protected]> #
# Blog Http://www.yunweijilu.com #
# Auto backup or inport Mysql Sql file to Mysql server #
#####################################################################
"
#Mysql SQL Data backup
mysql_sql_back(){
if [[ ! -d ${data_backup_dir} ]] ; then
mkdir -p $data_backup_dir
echo -e " \033[32mCreat $data_backup_dir Successful! \033[0m"
fi
if [ `ps aux | grep mysql|grep -v grep|wc -l` -eq "0" ];then
/etc/init.d/mysqld start
fi
$MYSQLDUMP -u$MYSQLUSR -p"$mysql_root_pass" --all-databases > $mysql_data_backup
if [[ $? -eq 0 ]];then
echo -e " \033[32m Backup Mysql Data success! \033[0m"
else
echo -e " \033[32m Back failed,pls check...\033[0m "
fi
}
#Mysql SQL Data import
mysql_sql_import(){
$mysql_cmd -u"$MYSQLUSR" -p"$mysql_root_pass" < $mysql_data_backup
}
#Mysql backup or import Menu
[ ! -d $mysql_local ] && echo -e "${RED}No Mysql Server in your System!!" && exit 1
if [ -z $1 ];then
echo -e "${WHITE}Usage {$0 backup|import}${WHITE}"
echo
else
echo -e "${YELLOW}"
read -p "Please input Mysql server root password : " mysql_root_pass
if [ $1 == "backup" ];then
echo -e "You select backup Mysql Data from $mysql_data"
mysql_sql_back
elif [ $1 == "import" ];then
echo -e "You select import Mysql Data to $data_backup_dir"
mysql_sql_import
else
echo -e "Usage {$0 backup|import}"
fi
fi
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/ZeBeiFeng/lnmp.git
[email protected]:ZeBeiFeng/lnmp.git
ZeBeiFeng
lnmp
lnmp
master

搜索帮助