当前位置:论坛首页 > Windows面板 > 求助

8.5.2备份排除问题

发表在 Windows面板5 天前 [复制链接] 1 87

为了能快速了解并处理您的问题,请提供以下基础信息:
面板、插件版本:bt:8.5.2  ftp5.4

系统版本:windows server 2012

问题描述:如果备份到本地,排除没有问题,如果备份到FTP,无法排除目录

相关截图(日志、错误):C:/BtSoft/cron/61148d23ccc854943f258911c36692df.log 2>&1 & "C:\\Program Files\\python\\python.exe" -u C:\BtSoft\panel\plugin\ftp\ftp_main.py site test.com 3 61148d23ccc854943f258911c36692df 61148d23ccc854943f258911c36692df >> C:/BtSoft/cron/61148d23ccc854943f258911c36692df.log 2>&1 & echo ------------------------------------END------------------------------------这样无法排除目录
备份到硬盘是echo ------------------------------------START--------------------------------- >> C:/BtSoft/cron/d63f6d814c6e727180ae466a042b96e5.log 2>&1 & C:\BtSoft\panel\btPanel.exe --tools backup_site test.net 3 d63f6d814c6e727180ae466a042b96e5 d63f6d814c6e727180ae466a042b96e5 >> C:/BtSoft/cron/d63f6d814c6e727180ae466a042b96e5.log 2>&1 & echo ------------------------------------END------------------------------------可以正常排除

使用道具 举报 只看该作者 回复
发表于 5 天前 | 显示全部楼层
问题出现在C:\BtSoft\panel\plugin\ftp\panelBackup.py
修改了一下代码,目前正常了,官方可以根据思路修改一下吧
  1. #coding: utf-8
  2. import public, db, re, os, time
  3. import zipfile, sys

  4. panelPath = os.getenv('BT_PANEL')
  5. os.chdir(panelPath)
  6. sys.path.insert(0, panelPath + "/class/")


  7. class panelBackup:

  8.     bin_file = None

  9.     def __init__(self):
  10.         self.get_bin_file()

  11.     def get_bin_file(self):
  12.         
  13.         self.bin_file = panelPath + '/btPanel.exe'
  14.         if not os.path.exists(self.bin_file):
  15.             self.bin_file = panelPath + "/aaPanel.exe"

  16.         if not os.path.exists(self.bin_file):
  17.             self.bin_file = panelPath + '/btPanel'

  18.     def get_backup_path(self):
  19.         backup_path = public.M('config').where("id=?", (1, )).getField('backup_path')

  20.         return backup_path

  21.     #备份网站
  22.     def backupSite(self, name):

  23.         # 默认调用方式
  24.         shell = "{} --tools backup_site {}".format(self.bin_file, name)

  25.         # FTP计划任务的参数:
  26.         # ftp_main.py site ALL 3 UUID UUID
  27.         #
  28.         # 将计划任务UUID继续传递给btPanel.exe,
  29.         # 使btPanel.exe能够读取:
  30.         # C:\BtSoft\cron\UUID.exclude
  31.         try:
  32.             if len(sys.argv) >= 6:
  33.                 count = sys.argv[3]
  34.                 key1 = sys.argv[4]
  35.                 key2 = sys.argv[5]

  36.                 if len(key1) == 32 and len(key2) == 32:
  37.                     shell = "{} --tools backup_site {} {} {} {}".format(
  38.                         self.bin_file,
  39.                         name,
  40.                         count,
  41.                         key1,
  42.                         key2
  43.                     )
  44.         except:
  45.             pass

  46.         print("执行备份命令: " + shell)

  47.         res = public.ExecShell(shell)[0]
  48.         print(res)

  49.         res = res.replace('\\', '/')
  50.         backup_path = self.get_backup_path().replace('\\', '/')

  51.         pattern = re.compile(r'{}\/.*\.zip'.format(backup_path))

  52.         match = re.search(pattern, res)
  53.         if not match:
  54.             print("未找到备份文件路径")
  55.             return ""

  56.         filename = match.group()

  57.         if not os.path.exists(filename):
  58.             return ""

  59.         return filename

  60.     #备份数据库
  61.     def backupDatabase(self, name):
  62.       
  63.         shell = "{} --tools backup_database {}".format(self.bin_file, name)
  64.         res = public.ExecShell(shell)[0]
  65.         print(res)

  66.         res = res.replace('\\', '/')
  67.         backup_path = self.get_backup_path().replace('\\', '/')

  68.         pattern = re.compile(r'{}\/.*'.format(backup_path))

  69.         match = re.search(pattern, res)
  70.         if not match:
  71.             return ""

  72.         filename = match.group()

  73.         if not os.path.exists(filename):
  74.             return ""

  75.         return filename

  76.     #备份指定目录
  77.     def backupPath(self, path):

  78.         shell = "{} --tools backup_path {}".format(self.bin_file, path)
  79.         res = public.ExecShell(shell)[0]
  80.         print(res)

  81.         res = res.replace('\\', '/')
  82.         backup_path = self.get_backup_path().replace('\\', '/')

  83.         pattern = re.compile(r'{}\/.*\.zip'.format(backup_path))

  84.         match = re.search(pattern, res)
  85.         if not match:
  86.             return ""

  87.         filename = match.group()

  88.         if not os.path.exists(filename):
  89.             return ""

  90.         return filename
复制代码
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表