|
@@ -19,6 +19,7 @@ printf "
|
|
"
|
|
"
|
|
|
|
|
|
. ./options.conf
|
|
. ./options.conf
|
|
|
|
+. ./versions.txt
|
|
. ./include/color.sh
|
|
. ./include/color.sh
|
|
. ./include/check_dir.sh
|
|
. ./include/check_dir.sh
|
|
. ./include/python.sh
|
|
. ./include/python.sh
|
|
@@ -34,9 +35,9 @@ while :; do echo
|
|
echo -e "\t${CMSG}4${CEND}. Localhost and Remote host"
|
|
echo -e "\t${CMSG}4${CEND}. Localhost and Remote host"
|
|
echo -e "\t${CMSG}5${CEND}. Localhost and Qcloud COS"
|
|
echo -e "\t${CMSG}5${CEND}. Localhost and Qcloud COS"
|
|
echo -e "\t${CMSG}6${CEND}. Remote host and Qcloud COS"
|
|
echo -e "\t${CMSG}6${CEND}. Remote host and Qcloud COS"
|
|
- read -p "Please input a number:(Default 1 press Enter) " DESC_BK
|
|
|
|
|
|
+ read -p "Please input a number:(Default 1 press Enter) " DESC_BK
|
|
[ -z "$DESC_BK" ] && DESC_BK=1
|
|
[ -z "$DESC_BK" ] && DESC_BK=1
|
|
- if [[ ! $DESC_BK =~ ^[1-6]$ ]];then
|
|
|
|
|
|
+ if [[ ! $DESC_BK =~ ^[1-6]$ ]]; then
|
|
echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
|
|
echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6${CEND}"
|
|
else
|
|
else
|
|
break
|
|
break
|
|
@@ -57,7 +58,7 @@ while :; do echo
|
|
echo -e "\t${CMSG}3${CEND}. Database and Website"
|
|
echo -e "\t${CMSG}3${CEND}. Database and Website"
|
|
read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK
|
|
read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK
|
|
[ -z "$CONTENT_BK" ] && CONTENT_BK=1
|
|
[ -z "$CONTENT_BK" ] && CONTENT_BK=1
|
|
- if [[ ! $CONTENT_BK =~ ^[1-3]$ ]];then
|
|
|
|
|
|
+ if [[ ! $CONTENT_BK =~ ^[1-3]$ ]]; then
|
|
echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
|
|
echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
|
|
else
|
|
else
|
|
break
|
|
break
|
|
@@ -68,10 +69,10 @@ done
|
|
[ "$CONTENT_BK" == '2' ] && sed -i 's@^backup_content=.*@backup_content=web@' ./options.conf
|
|
[ "$CONTENT_BK" == '2' ] && sed -i 's@^backup_content=.*@backup_content=web@' ./options.conf
|
|
[ "$CONTENT_BK" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf
|
|
[ "$CONTENT_BK" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf
|
|
|
|
|
|
-if [ "$DESC_BK" != '3' ];then
|
|
|
|
|
|
+if [ "$DESC_BK" != '3' ]; then
|
|
while :; do echo
|
|
while :; do echo
|
|
echo "Please enter the directory for save the backup file: "
|
|
echo "Please enter the directory for save the backup file: "
|
|
- read -p "(Default directory: $backup_dir): " NEW_backup_dir
|
|
|
|
|
|
+ read -p "(Default directory: $backup_dir): " NEW_backup_dir
|
|
[ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
|
|
[ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
|
|
if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
|
|
if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
|
|
echo "${CWARNING}input error! ${CEND}"
|
|
echo "${CWARNING}input error! ${CEND}"
|
|
@@ -84,13 +85,13 @@ fi
|
|
|
|
|
|
while :; do echo
|
|
while :; do echo
|
|
echo "Pleas enter a valid backup number of days: "
|
|
echo "Pleas enter a valid backup number of days: "
|
|
- read -p "(Default days: 5): " expired_days
|
|
|
|
|
|
+ read -p "(Default days: 5): " expired_days
|
|
[ -z "$expired_days" ] && expired_days=5
|
|
[ -z "$expired_days" ] && expired_days=5
|
|
[ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}"
|
|
[ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}"
|
|
done
|
|
done
|
|
sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
|
|
sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
|
|
|
|
|
|
-if [ "$CONTENT_BK" != '2' ];then
|
|
|
|
|
|
+if [ "$CONTENT_BK" != '2' ]; then
|
|
databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"`
|
|
databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"`
|
|
while :; do echo
|
|
while :; do echo
|
|
echo "Please enter one or more name for database, separate multiple database names with commas: "
|
|
echo "Please enter one or more name for database, separate multiple database names with commas: "
|
|
@@ -129,17 +130,17 @@ echo "You have to backup the content:"
|
|
[ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}"
|
|
[ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}"
|
|
[ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}"
|
|
[ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}"
|
|
|
|
|
|
-if [[ "$DESC_BK" =~ ^[2,4,6]$ ]];then
|
|
|
|
|
|
+if [[ "$DESC_BK" =~ ^[2,4,6]$ ]]; then
|
|
> tools/iplist.txt
|
|
> tools/iplist.txt
|
|
while :; do echo
|
|
while :; do echo
|
|
read -p "Please enter the remote host ip: " remote_ip
|
|
read -p "Please enter the remote host ip: " remote_ip
|
|
[ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
|
|
[ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
|
|
echo
|
|
echo
|
|
read -p "Please enter the remote host port(Default: 22) : " remote_port
|
|
read -p "Please enter the remote host port(Default: 22) : " remote_port
|
|
- [ -z "$remote_port" ] && remote_port=22
|
|
|
|
|
|
+ [ -z "$remote_port" ] && remote_port=22
|
|
echo
|
|
echo
|
|
read -p "Please enter the remote host user(Default: root) : " remote_user
|
|
read -p "Please enter the remote host user(Default: root) : " remote_user
|
|
- [ -z "$remote_user" ] && remote_user=root
|
|
|
|
|
|
+ [ -z "$remote_user" ] && remote_user=root
|
|
echo
|
|
echo
|
|
read -p "Please enter the remote host password: " remote_password
|
|
read -p "Please enter the remote host password: " remote_password
|
|
IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
|
|
IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
|
|
@@ -147,11 +148,11 @@ if [[ "$DESC_BK" =~ ^[2,4,6]$ ]];then
|
|
PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
|
|
PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
|
|
[ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
|
|
[ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
|
|
./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
|
|
./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
|
|
- if [ $? -eq 0 ];then
|
|
|
|
|
|
+ if [ $? -eq 0 ]; then
|
|
[ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}"
|
|
[ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}"
|
|
while :; do
|
|
while :; do
|
|
- read -p "Do you want to add more host ? [y/n]: " more_host_yn
|
|
|
|
- if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ];then
|
|
|
|
|
|
+ read -p "Do you want to add more host ? [y/n]: " more_host_yn
|
|
|
|
+ if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ]; then
|
|
echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
|
|
echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
|
|
else
|
|
else
|
|
break
|
|
break
|
|
@@ -162,26 +163,25 @@ if [[ "$DESC_BK" =~ ^[2,4,6]$ ]];then
|
|
done
|
|
done
|
|
fi
|
|
fi
|
|
|
|
|
|
-if [[ "$DESC_BK" =~ ^[3,5,6]$ ]];then
|
|
|
|
|
|
+if [[ "$DESC_BK" =~ ^[3,5,6]$ ]]; then
|
|
[ ! -e "${python_install_dir}/bin/python" ] && Install_Python
|
|
[ ! -e "${python_install_dir}/bin/python" ] && Install_Python
|
|
[ ! -e "${python_install_dir}/lib/python2.7/site-packages/requests" ] && ${python_install_dir}/bin/pip install requests
|
|
[ ! -e "${python_install_dir}/lib/python2.7/site-packages/requests" ] && ${python_install_dir}/bin/pip install requests
|
|
while :; do echo
|
|
while :; do echo
|
|
echo 'Please select your backup datacenter:'
|
|
echo 'Please select your backup datacenter:'
|
|
- echo -e "\t ${CMSG}1${CEND}. 华南(广州) ${CMSG}2${CEND}. 华北(天津)"
|
|
|
|
|
|
+ echo -e "\t ${CMSG}1${CEND}. 华南(广州) ${CMSG}2${CEND}. 华北(天津)"
|
|
echo -e "\t ${CMSG}3${CEND}. 华东(上海) ${CMSG}4${CEND}. 新加坡"
|
|
echo -e "\t ${CMSG}3${CEND}. 华东(上海) ${CMSG}4${CEND}. 新加坡"
|
|
read -p "Please input a number:(Default 1 press Enter) " Location
|
|
read -p "Please input a number:(Default 1 press Enter) " Location
|
|
[ -z "$Location" ] && Location=1
|
|
[ -z "$Location" ] && Location=1
|
|
if [ ${Location} -ge 1 >/dev/null 2>&1 -a ${Location} -le 4 >/dev/null 2>&1 ]; then
|
|
if [ ${Location} -ge 1 >/dev/null 2>&1 -a ${Location} -le 4 >/dev/null 2>&1 ]; then
|
|
break
|
|
break
|
|
else
|
|
else
|
|
- echo "${CWARNING}input error! Please only input number 1~4${CEND}"
|
|
|
|
|
|
+ echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
|
|
fi
|
|
fi
|
|
done
|
|
done
|
|
[ "$Location" == '1' ] && region=gz
|
|
[ "$Location" == '1' ] && region=gz
|
|
[ "$Location" == '2' ] && region=tj
|
|
[ "$Location" == '2' ] && region=tj
|
|
[ "$Location" == '3' ] && region=sh
|
|
[ "$Location" == '3' ] && region=sh
|
|
[ "$Location" == '4' ] && region=sgp
|
|
[ "$Location" == '4' ] && region=sgp
|
|
- [ -e "/root/.coscredentials" ] && rm -rf /root/.coscredentials
|
|
|
|
while :; do echo
|
|
while :; do echo
|
|
read -p "Please enter the Qcloud COS appid: " appid
|
|
read -p "Please enter the Qcloud COS appid: " appid
|
|
[ -z "$appid" ] && continue
|
|
[ -z "$appid" ] && continue
|