whhack 发表于 2026-8-9 22:03:20

8.5.2备份排除问题

为了能快速了解并处理您的问题,请提供以下基础信息:面板、插件版本:bt:8.5.2ftp5.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------------------------------------可以正常排除

whhack 发表于 2026-8-9 22:57:11

问题出现在C:\BtSoft\panel\plugin\ftp\panelBackup.py
修改了一下代码,目前正常了,官方可以根据思路修改一下吧
#coding: utf-8
import public, db, re, os, time
import zipfile, sys

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


class panelBackup:

    bin_file = None

    def __init__(self):
      self.get_bin_file()

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

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

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

      return backup_path

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

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

      # FTP计划任务的参数:
      # ftp_main.py site ALL 3 UUID UUID
      #
      # 将计划任务UUID继续传递给btPanel.exe,
      # 使btPanel.exe能够读取:
      # C:\BtSoft\cron\UUID.exclude
      try:
            if len(sys.argv) >= 6:
                count = sys.argv
                key1 = sys.argv
                key2 = sys.argv

                if len(key1) == 32 and len(key2) == 32:
                  shell = "{} --tools backup_site {} {} {} {}".format(
                        self.bin_file,
                        name,
                        count,
                        key1,
                        key2
                  )
      except:
            pass

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

      res = public.ExecShell(shell)
      print(res)

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

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

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

      filename = match.group()

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

      return filename

    #备份数据库
    def backupDatabase(self, name):
      
      shell = "{} --tools backup_database {}".format(self.bin_file, name)
      res = public.ExecShell(shell)
      print(res)

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

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

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

      filename = match.group()

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

      return filename

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

      shell = "{} --tools backup_path {}".format(self.bin_file, path)
      res = public.ExecShell(shell)
      print(res)

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

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

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

      filename = match.group()

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

      return filename
页: [1]
查看完整版本: 8.5.2备份排除问题