首页 > 代码库 > pyhont备份php代码脚本
pyhont备份php代码脚本
#!/usr/bin/env python # encoding: utf-8 import time import os import sys import logging #create logger logger = logging.getLogger("phpfile") logger.setLevel(logging.DEBUG) #create console handler and set level to error ch = logging.StreamHandler() ch.setLevel(logging.ERROR) #create file handler and set level to debug fh = logging.FileHandler("phpfile.log") fh.setLevel(logging.DEBUG) #create formatter formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") #add formatter to ch and fh ch.setFormatter(formatter) fh.setFormatter(formatter) #add ch and fh to logger logger.addHandler(ch) logger.addHandler(fh) def backup(): source = [‘/apps/emc_nas/cms/activity‘,‘/apps/emc_nas/cms/phpcms‘] #source = [‘/apps/emc_nas/cms/activity‘] target_dir = ‘/apps/emc_nas/bak/cms_backup/‘ today = target_dir + time.strftime(‘%Y%m%d‘) now = "phpcms_" + time.strftime(‘%Y%m%d‘) if not os.path.exists(today): os.mkdir(today) print ‘Successfully created directory‘, today logger.info(today) target = today + os.sep + now + ‘.tar.gz‘ logger.debug(target) tar_backup = "tar -zcvf %s %s" % (target,‘ ‘.join(source)) logger.info(tar_backup) if os.system(tar_backup) == 0: print "Successful backup to ", target else: print "Backup FAILED!!" logger.debug(tar_backup) if __name__ == "__main__": backup()
pyhont备份php代码脚本
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。