> ## Documentation Index
> Fetch the complete documentation index at: https://ayakaleaf-pro.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 导出项目

在 Server Pro 和社区版 `5.4.0` 中，我们提供了一个脚本，允许管理员将所有用户项目（包括仍显示在**已删除**和**回收站**文件夹中的项目）导出到磁盘上的某个目录。

<Info>
  运行此脚本的输出与从用户项目面板手动下载所有项目的 Zip 文件相同。该脚本会在开始下载前刷新所有待处理的更改，以确保导出内容包含项目的最新版本。
</Info>

### 限制

导出脚本有以下限制：

* 不会导出任何项目设置，例如 TeX Live 镜像名称或编译器。这些设置必须在项目上传到用户账户时重新设置。
* 导出的项目不包含任何版本历史。
* 不会保留任何协作者信息。项目需要重新共享。如果使用链接共享，查看和编辑链接将重新生成（与之前的链接不同）。
* 所有评论和修订跟踪信息都不会被导出。
* 项目聊天记录不会被导出。

<Danger>
  此脚本**并非**用于替代完整的系统备份。为确保你能在灾难恢复场景中恢复实例，我们**强烈**建议进行一次[一致性备份](https://docs.overleaf.com/on-premises/maintenance/#performing-a-consistent-backup)。
</Danger>

### **参数**

| 名称 | 描述 |
| - | - |
| `--help` | 显示帮助 |
| `--user-id` | 用户 ID（除非使用 `--export-all` 或 `--project-id`，否则为必需） |
| `--project-id` | 导出单个项目（**不能**与 `--user-id` 或 `--export-all` 一起使用） |
| `--list` | 列出用户的项目（**不能**与 `--output` 一起使用） |
| `--output` | 输出的 zip 文件（用于单项导出操作） |
| `--export-all` | 导出所有用户的项目（需要 `--output-dir`） |
| `--output-dir` | 用于存储所有用户导出文件的目录 |
| `--log-level` | 支持的日志级别：`trace`\|`debug`\|`info`\|`warn`\|`error`\|`fatal` |

### **用法**

使用以下命令导出所有用户的项目：

```bash wrap theme={null}
# Overleaf Toolkit users
$ bin/docker-compose exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/export-user-projects.mjs --export-all --output-dir=/var/lib/overleaf/data/exports"

# Legacy docker-compose.yml users
docker exec sharelatex /bin/bash -ce "cd /overleaf/services/web && node modules/server-ce-scripts/scripts/export-user-projects.mjs --export-all --output-dir=/var/lib/overleaf/data/exports"
```

<Info>
  如果你运行的是 Server Pro 或社区版 \<= 3.5.13，则需要将上述示例改为使用 **`export-legacy-user-projects.js`** 脚本。
</Info>

### **完成**

导出完成后，你可以通过主机上的目录访问这些文件：该目录是 **docker-compose.yml** 文件中绑定挂载到 <strong>/var/lib/overleaf</strong> 的目录；如果你使用的是 Toolkit，则是 **config/overleaf.rc** 文件中 `OVERLEAF_DATA_PATH` 环境变量指定的目录。

<Info>
  Overleaf 目前允许项目名称重复。如果某个用户有重名项目，这些项目仍会被添加到该用户的 Zip 导出文件中，但解压时只会保留一个版本。在 Linux 上，`unzip -B` 会将同名文件写为备份文件，而不是直接覆盖。
</Info>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.