php服务器版本更新工具up2server
为什么要做这个工具
之前做php 开发的时候,每次版本更新,要把修改的文件同步到服务器,都要小心翼翼,如果漏掉了文件,那就完蛋了,KPI,奖金什么的都没了。
所以写了这个工具。代码在github https://github.com/foxswang/up2server
1. 复制 获取要上传的文件 运行
python get_upload_file.py
get_upload_file.py的代码如下:
#!/usr/bin/python
import os
import os.path
import shutil
import time, datetime
import string fromdir = "source_folder"
todir = "backup"
filename = 'filelist.txt' #
def cpFile(srcPath, destPath):
shutil.copy(srcPath,destPath)
#shutil.copytree(srcPath,destPath)
#
def copyFiles(sourceDir, targetDir):
if sourceDir.find(".svn") > 0:
return
for file in os.listdir(sourceDir):
sourceFile = os.path.join(sourceDir, file)
targetFile = os.path.join(targetDir, file)
if os.path.isfile(sourceFile):
if not os.path.exists(targetDir):
os.makedirs(targetDir)
if not os.path.exists(targetFile) or(os.path.exists(targetFile) and (os.path.getsize(targetFile) != os.path.getsize(sourceFile))):
open(targetFile, "wb").write(open(sourceFile, "rb").read())
if os.path.isdir(sourceFile):
First_Directory = False
copyFiles(sourceFile, targetFile)
#
if __name__ == "__main__":
text_file = open("./"+filename ,"r")
#current_path = os.getcwd()
current_path = os.getcwd()
all_line = 0
folder_count = 0;
print("current_path "+ current_path )
if not os.path.exists(os.path.join(current_path, todir) ):
os.makedirs(os.path.join(current_path, todir) )
for line in text_file:
line=line.strip('\n')
srcFile = current_path + line
dstFile = current_path + '/' + todir + line
targetDir = os.path.dirname(dstFile)
if not os.path.isfile(srcFile):
folder_count = folder_count+1
continue;
print (srcFile)
print (dstFile)
if not os.path.exists(targetDir):
os.makedirs(targetDir)
print("cp "+ srcFile +" to " + dstFile)
cpFile(srcFile,dstFile)
all_line = all_line + 1 print ("copy success file : %d folder: %d" % (all_line,folder_count))
2. 备份服务器的文件,方便升级失败后进行恢复:
python backup_server_files.py
3. 将第一步复制的文件,上传到服务器
服务器版本升级so easy
文件和一些参数说明
1. 确保系统安装了python(windows 和linux 都支持)
2 .get_upload_files.py
获取需要上传到服务器上的文件列表,并保存到指定的文件夹
源文件的目录
fromdir = "source_folder"
根据filelist.txt 复制的文件存储目录
todir = "backup"
需要上传服务器的文件列表
filename = 'filelist.txt'
3.backup_server_files.py
备份目录文件
todir = "backup"
需要备份的文件列表
filename = 'filelist.txt'
服务器的代码路径,记住最后的 / 需要保留
SRC_FOLDER = ‘/path_to_server_src_folder/‘
4.filelist.txt 这个文件存储需要上传的文件
git如何获取需要上传的文件
git diff --name-status HEAD~2 HEAD~3
git diff
git diff b45ba47d1b297217e3ec6a3ab0f61716a8d6ecbc c244d0bf06d56ec86aaedeefa5dcd84dd9febc60
一般来说,通过 hash 串的前 4~6 位就可以区分,所示可以简写为:
git diff b45b 355e
git diff这个命令能比较两个提交之间的差异,使用–name-only参数可以只显示文件名。例如: $ git diff 608e120 4abe32e --name-only
php服务器版本更新工具up2server的更多相关文章
- 无法从命令行或调试器启动服务,必须首先安装Windows服务(使用installutil.exe),然后用ServerExplorer、Windows服务器管理工具或NET START命令启动它
无法从命令行或调试器启动服务,必须首先安装Windows服务(使用installutil.exe),然后用ServerExplorer.Windows服务器管理工具或NET START命令启动它 1. ...
- 新一代服务器性能测试工具Gatling
新一代服务器性能测试工具Gatlinghttp://automationqa.com/forum.php?mod=viewthread&tid=2898&fromuid=2
- windows10 专业版的远程服务器管理工具下载
一.安装远程服务器管理工具: 下载地址: https://www.microsoft.com/zh-cn/download/details.aspx?id=45520 二.关闭远程服务器管理工具: 1 ...
- Linux可视化服务器管理工具webmin
webmin是一个可视化的linux服务器管理工具,可以帮助我们实现很多功能. Webmin官网: http://www.webmin.com/ 下载地址:http://prdownloads.sou ...
- Gatling新一代压力测试工具,新一代服务器性能测试工具Gatling
Gatling新一代压力测试工具新一代服务器性能测试工具Gatlinghttp://www.infoq.com/cn/articles/new-generation-server-testing-to ...
- Web界面的服务器监测工具(转载)
企业服务器对于企业业务持续性意义重大,系统管理员需要密切关注企业服务器以确保一切正常运行.当发现问题的时候,他们需要知道问题开始出现时的状况,因此调查可以重点放在问题出现的时候,这就意味着定期记录信息 ...
- DELL服务器管理工具和RACADM介绍
DELL服务器管理工具和RACADM介绍 一.Dell服务器管理工具介绍 Dell对服务器(DELL PowerEdge)的管理主要提供了三种管理工具,分别是Dell Remote Access Co ...
- [转帖]服务器备份工具:Amanda,Bakula,Clonezilla,Rsnapshot,Mondo Rescue
服务器备份工具:Amanda,Bakula,Clonezilla,Rsnapshot,Mondo Rescue https://ywnz.com/linuxyffq/5270.html 改天试用一下. ...
- (视频) 基于HTML5的服务器远程访问工具
现在云计算这么发达,基本上每个人都多少有几台Windows或者Linux服务器运行在云端,要直接进入这些服务器进行配置就需要使用类似远程桌面或者Putty这类的工具,虽然大多数Windows电脑都自带 ...
随机推荐
- SQL SERVER 内存分配及常见内存问题 DMV查询
内存动态管理视图(DMV): 从sys.dm_os_memory_clerks开始. SELECT [type] , SUM(virtual_memory_reserved_kb) AS [VM R ...
- Android中Services之异步IntentService
IntentService:异步处理服务,新开一个线程:handlerThread在线程中发消息,然后接受处理完成后,会清理线程,并且关掉服务. IntentService有以下特点: (1) 它创 ...
- Windows Azure HandBook (3) 浅谈Azure安全性
<Windows Azure Platform 系列文章目录> 2015年3月5日-6日,参加了上海的Azure University活动.作为桌长与微软合作伙伴交流了Azure相关的技术 ...
- SQL Server中的事务日志管理(9/9):监控事务日志
当一切正常时,没有必要特别留意什么是事务日志,它是如何工作的.你只要确保每个数据库都有正确的备份.当出现问题时,事务日志的理解对于采取修正操作是重要的,尤其在需要紧急恢复数据库到指定点时.这系列文章会 ...
- Moon.Orm 5.0(MQL版)分页功能的设计(求指教,邀请您的加入)
一.分页的分类及分析 1)分页的前置条件: 查询的目标条件.第几页.总页数(本质上由查询条件决定).每页条数.请求地址.按照什么字段怎样排序 2)目标结果: 数据列表,List<T>返回 ...
- 做一个会PS切图的前端开发
系列链接 做一个会使用PS的前端开发 做一个会PS切图的前端开发 切图方法分类 PhotoShop从CS版本演变到现在的CC版本,切图功能发生了比较大的变化,我们可以把PhotoShop CS版本时的 ...
- MyKTV
namespace MyKTVClient{ public partial class FrmOrderBySinger : Form { private string singerSex = &qu ...
- 一个不错的php验证码的类
类的代码: <?php class Captcha { private $width; private $height; private $codeNum; private $code; pri ...
- iOS阶段学习第四天笔记(循环)
iOS学习(C语言)知识点整理笔记 一.分支结构 1.分支结构分为单分支 即:if( ){ } ;多分支 即:if( ){ }else{ } 两种 2.单分支 if表达式成立则执行{ }里的语句:双 ...
- nested exception is org.hibernate.QueryException: could not resolve property
SSH框架出现了下面的错误: nested exception is org.hibernate.QueryException: could not resolve property 检查了hbm.x ...