1, 上传文件命令:
文件+空格+[需要上传的文件的绝对路径] [arg...]
./scp.mc.up.sh /Users/jerryxu/wwwroot/cache/server/backup/1115just4/run.sh
count=1 while [ "$#" -ge "1" ];do echo "参数序号为 $count 是 $1" DATE=`date +%F | sed 's/-//g'``date +%T | sed 's/://g'` scp -r -P 7822 $1 %Host%:/home/justuniq/mc_xu/up_file let count=count+1 shift done echo "执行完成!"
%Host% 主机
2, 下载文件命令
文件+空格+【服务器绝对路径] 【arg...】
./scp.mc.down.sh /home/justuniq/mc_xu/xu_sh_backup/justuniq_just4_20190119034902.sql
count=1 while [ "$#" -ge "1" ];do echo "参数序号为 $count 是 $1" scp -r -P 7822 %Host%:$1 /Users/jerryxu/wwwroot/cache/server/backup let count=count+1 shift done
3, 导入SQL到数据库命令:
文件+空格+[需要导入的文件的绝对路径] [arg...]
./mysql_import.sh /Users/jerryxu/wwwroot/cache/server/backup/justuniq_just4_20190423100022.sql
count=1 while [ "$#" -ge "1" ];do echo "参数序号为 $count 是 $1" DATE=`date +%F | sed 's/-//g'``date +%T | sed 's/://g'` var=$1 socket=/Applications/MAMP/tmp/mysql/mysql.sock user=%用户名% password=%密码% mycmd="mysql -u$user -p$password -S $socket" $mycmd -e "drop database $(basename ${var} .sql)"; #创建数据库 $mycmd -e "create database $(basename ${var} .sql)"; $mycmd -e "show databases;" #source $1 $mycmd -f "$(basename ${var} .sql)" -e "source $1" let count=count+1 shift done echo "执行完成!"
%用户名% %密码%
4,数据库导出命令:
文件+空格+[数据库名称] [arg...]
/mysqldump.sh justuniq_just4_20190423100022
acount=1 while [ "$#" -ge "1" ];do echo "参数序号为 $count 是 $1" DATE=`date +%F | sed 's/-//g'``date +%T | sed 's/://g'` if [ -d "../xu_sh_backup" ];then echo "文件夹存在" else mkdir ../xu_sh_backup fi mysqldump -uroot -proot $1 >../xu_sh_backup/$1"_"$DATE.sql let count=count+1 shift done echo "执行完成!"
5, iterm2 配置 ssh 文件
#!/usr/bin/expect -f set port [端口] set user [用户名] set host [服务器地址] set password [密码] set timeout -1 spawn ssh -p $port $user@$host expect "*assword:*" send "$password " interact expect eof