# sync_web **Repository Path**: hellstar/sync_web ## Basic Information - **Project Name**: sync_web - **Description**: 将本地的修改通过ftp一键同步到服务器上 ,非常适合维护多个网站并且经常改动代码的情况 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 15 - **Created**: 2014-01-10 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README sync_web ======= 将本地的修改通过ftp一键同步到服务器上 ,非常适合维护多个网站并且经常改动代码的情况(监测文件变动依赖于svn或git) author: **hellstar** 在[ksc](http://blog.geekli.cn)的sync_web项目基础上改进 > 需要安装python2.7环境与svn客户端、git客户端(确保svn,git所在目录加入到环境变量path中) > 第三方python工具包 paramiko,用于支持sftp ###用法 * 更新所有站点 sync_web -s all * 更新名称为test的站点 sync_web -s test * 列出所有站点 sync_web -l * 查看帮助 sync_web -h ###paramiko的安装 > 安装包位于third目录下 > 先安装pycrypto, pycrypto直接安装比较麻烦,可用已编译好的安装文件,[下载地址](http://www.voidspace.org.uk/python/modules.shtml#pycrypto) > 再安装ecdsa > 最后安装paramiko > [paramiko官方主页](https://github.com/paramiko/paramiko) [paramiko文档](http://docs.paramiko.org/) ###配置文件 配置文件默认和脚本在同一目录下,名称为config.ini [site] #站点数量 sitenum=4 #1-第一个站点的名字 2-第二个站点的名字 以此类推 1=trade 2=sms 3=tradmin 4=sftp [remote_trade] #传输模式 ftp-ftp协议 sftp-sftp协议,通过ssh传输 mode = ftp host = www.test.com port = 21 user = test passwd = test #主动模式 true-主动模式 false-被动模式,ftp模式下需配置 passive = True #是否启用ssl,ftp模式下需配置 ssl = True #网址相对于ftp根目录的绝对地址 webroot = /public_html/ [local_trade] local_webroot = D:/9meal/ #version_control版本控制软件 支持svn,git version_control=svn #include_path 需要强制检测的目录,不依赖于版本控制软件,支持多级目录path1/path2 #也就是说即使版本控制忽略了该目录,只有该目录下有文件变动,也会自动上传到服务器 #多个目录用英文逗号"," 分割path1,path2 include_path= #exclude_path,排除在外的目录,支持多级目录 path1/path2 #多个目录用英文逗号","分割path1,path2 exclude_path= #exclude_file,排除在外的文件,支持目录 path1/file1 #多个文件用英文逗号","分割file1,file2 exclude_file= #最后更新时间 格式 2014-01-09 00:00:00 lasttime = 2014-01-09 00:00:00 [remote_sms] mode = ftp host = www.test.com port = 21 user = test passwd = test passive = True ssl = True webroot = /sms/ [local_sms] local_webroot = D:/9meal/sms/ version_control=svn include_path= exclude_path= exclude_file= lasttime = 2014-01-09 00:00:00 [remote_tradmin] mode = ftp host = www.test.com port = 21 user = test passwd = test passive = True ssl = True webroot = /sms/ [local_tradmin] local_webroot = D:/tradmin/ version_control=svn include_path= exclude_path= exclude_file= lasttime = 2014-01-09 00:00:00 [remote_sftp] mode = sftp host = www.test.com port = 21 user = test passwd = test webroot = /sms/ [local_sftp] local_webroot = D:/tradmin/ version_control=svn include_path= exclude_path= exclude_file= lasttime = 2014-01-09 00:00:00 ###注意事项 webroot >网站的绝对路径是 /var/www/web/ 但是ftp登陆后的根目录是/var/www/ 也就是说不能再往上走了 那么你的webroot 填写 /web/就可以了 include_path >include_path 需要强制检测的目录,不依赖于版本控制软件 也就是说即使版本控制忽略了该目录,只有该目录下有文件变动,也会自动上传到服务器 另外程序是根据时间戳进行检测的,所以对那些修改名称(文件内容没有变化)的并不会检测到 ###计划