diff --git a/bin/backup.sh b/bin/backup.sh index d4eba8c..7dc32a5 100755 --- a/bin/backup.sh +++ b/bin/backup.sh @@ -209,7 +209,8 @@ backup_folders() { # 执行打包 log_info "开始打包文件夹..." log_info "排除规则: ${exclude_args}" - if eval "tar -czf '${folders_tar}' ${exclude_args} ${tar_sources}" 2>&1; then + # 将 tar 输出重定向到 stderr,避免干扰函数返回值 + if eval "tar -czf '${folders_tar}' ${exclude_args} ${tar_sources}" 2>&1 >&2; then local tar_size=$(du -h "${folders_tar}" | cut -f1) log_info "文件夹备份完成: ${folders_tar} (大小: ${tar_size})" echo "${folders_tar}"