问题出现在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[3]
- key1 = sys.argv[4]
- key2 = sys.argv[5]
- 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)[0]
- 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)[0]
- 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)[0]
- 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
复制代码 |