本地文件与服务器文件同步shell脚本,
本地文件与服务器文件同步shell脚本,
为何创建此脚本是因为方便项目的布署,不需要手动地去同步不同的项目,而只需要简单的执行shell脚本,输入项目名就能发布到服器上。
1、shell文件代码
#!/bin/sh read -t 30 -p "请输入项目名:" name echo -e "\n" echo "项目名为:$name" case $name in cn) rsync -r ~/project1 root@192.168.18.2:/project1 --exclude="test.css" --progress ;; cnb2b) rsync -r ~/project2 root@192.168.18.2:/web/project2 --exclude="node_modules" --progress ;; *) echo "Ignorant" ;; esac echo "同步完成"
2、关键字解释:
name表示要同步的文件名
--exculde="node_modules"表示过滤的文件夹
--progress 显示文件同步进程
3、文件新建并保存
将文件保存为name.sh
使用. name.sh执行文件
4、具体进程;
评论暂时关闭