> For the complete documentation index, see [llms.txt](https://ayakaleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ayakaleaf-pro.ayaka.space/on-premises/ko/maintenance/s3-migration.md).

# S3 마이그레이션

## S3 마이그레이션

{% hint style="info" %}
이 지침은 v5.x 이상을 위한 것입니다. 이전 버전에 대해 이 가이드를 따르고 있다면 다음을 사용하세요 `sharelatex` 대신 `overleaf` 경로 이름과 `SHARELATEX_` 대신 접두사 `OVERLEAF_` 환경 변수에 사용합니다.
{% endhint %}

{% hint style="warning" %}
Server Pro 고객: 데이터를 S3로 마이그레이션하기 전에 지원팀에 문의해 주세요.
{% endhint %}

{% hint style="success" %}
**여러분의 의견을 듣고 싶습니다!** 마이그레이션한 파일 수, 전체 용량, 그리고 마이그레이션에 걸린 시간을 공유해 주시려면 다음으로 이메일을 보내 주세요 [`support@overleaf.com`](mailto:support@overleaf.com) .
{% endhint %}

이 가이드는 디스크 기반 저장소에서 S3 호환 오브젝트 스토리지로의 마이그레이션 과정을 안내합니다. 이는 다음의 소개 문서 섹션을 참조합니다: [S3 설정](/on-premises/ko/configuration/overleaf-toolkit/s3.md).

### 요구 사항

* 연결할 S3 호환 오브젝트 스토리지가 필요합니다. 옵션은 다음을 참조하세요: [S3](/on-premises/ko/configuration/overleaf-toolkit/s3.md#s3-setup) 옵션은
* 기존 데이터를 마이그레이션할 여유 디스크 공간. 현재 디스크 사용량 정도
* 실제 마이그레이션을 수행할 유지보수 시간
* 복구할 수 있도록 설정을 포함한 전체 백업

### 마이그레이션에 필요한 디스크 크기 추정

다음을 사용할 수 있습니다 `du` 현재 디스크 사용량을 계산하기 위해:

```shell
docker exec sharelatex \\
  du --human-readable --max-depth=0 /var/lib/overleaf/data/user_files

docker exec sharelatex \\
  du --human-readable --max-depth=0 /var/lib/overleaf/data/template_files
```

현재 서버에서 사용 가능한 디스크 공간이 충분하지 않다면, 서버에 다른 디스크를 연결해 보세요.

{% hint style="info" %}
history 디렉터리는 이미 올바른 구조를 가지고 있습니다. 추가 디스크 공간이 필요 없는 bind-mounted source folder에서 직접 업로드할 수 있습니다.
{% endhint %}

### 마이그레이션 단계

#### 단계 0 인스턴스 종료

모든 사용자/템플릿 파일이 마이그레이션되도록 해야 합니다. 새로 업로드된 파일을 놓치지 않도록 인스턴스를 종료하는 것이 가장 좋습니다.

종료 절차는 일관된 백업 수행 가이드를 참고하세요.

#### 단계 1 디렉터리 구조 다시 쓰기

S3에 업로드하기 위해 프로젝트 파일의 디렉터리 구조를 다시 작성해야 합니다. filestore의 로컬 저장소 디렉터리 구조는 `<project-id>_<file-id>` 그리고 S3의 디렉터리 구조는 `<project-id>/<file-id>`.

다음에서 `/srv/overleaf-s3-migration` 새 디렉터리 구조로 파일을 저장하는 데 사용됩니다.

다음을 활용할 수 있습니다 `tar` 구조를 다시 쓰기 위해:

```shell
mkdir -p /srv/overleaf-s3-migration/user_files \\
         /srv/overleaf-s3-migration/template_files
docker exec sharelatex \\
  tar --create --directory /var/lib/overleaf/data/user_files . \\
| tar --extract --directory /srv/overleaf-s3-migration/user_files \\
  --transform=sx_x/x
docker exec sharelatex \\
  tar --create --directory /var/lib/overleaf/data/template_files . \\
| tar --extract --directory /srv/overleaf-s3-migration/template_files \\
  --transform=sx_x/xg
```

#### 단계 2 파일 업로드

선호에 따라 파일을 S3 호환 오브젝트 스토리지에 업로드할 때 minio mc S3 클라이언트 또는 aws cli를 사용할 수 있습니다.

**aws cli**

{% hint style="info" %}

* 여기서 다음을 바꾸어야 합니다 `overleaf-user-files`, `overleaf-template-files`, `overleaf-project-blobs` 및 `overleaf-chunks` S3 버킷 이름으로
* 또한 다음도 바꾸세요 `/srv/overleaf-bind-mount` 의 로컬 경로로 `/var/lib/overleaf` bind-mount를. 기본값은 다음과 같습니다: `~/overleaf_data` docker-compose.yml 배포에서는 그리고 `<toolkit-checkout>/data/overleaf` Toolkit을 사용할 때는.
  {% endhint %}

{% code overflow="wrap" %}

```shell
aws s3 sync /srv/overleaf-s3-migration/user_files s3://overleaf-user-files
aws s3 sync /srv/overleaf-s3-migration/template_files s3://overleaf-template-files

aws s3 sync /srv/overleaf-bind-mount/data/history/overleaf-project-blobs s3://overleaf-project-blobs
aws s3 sync /srv/overleaf-bind-mount/data/history/overleaf-chunks s3://overleaf-chunks
```

{% endcode %}

**minio mc**

여기서는 서버 별칭 "s3"를 사용하고 있습니다. 다른 이름을 선택했을 수도 있습니다.

{% code overflow="wrap" %}

```shell
mc mirror /srv/overleaf-s3-migration/user_files s3/overleaf-user-files
mc mirror /srv/overleaf-s3-migration/template_files s3/overleaf-template-files

mc mirror /srv/overleaf-bind-mount/data/history/overleaf-project-blobs s3/overleaf-project-blobs
mc mirror /srv/overleaf-bind-mount/data/history/overleaf-chunks s3/overleaf-chunks
```

{% endcode %}

#### 단계 3 S3를 가리키도록 인스턴스 시작

config에 S3 관련 변수를 모두 추가하세요. 이는 다음에 자세히 설명되어 있습니다: [변수 개요](/on-premises/ko/configuration/overleaf-toolkit/s3.md#overview-of-variables) 섹션의 [S3](https://docs.overleaf.com/on-premises/configuration/overleaf-toolkit/s3) 설정 가이드.

Docker Compose 배포의 경우 volumes 섹션에서 데이터 디렉터리에 대한 bind-mount를 제거할 수도 있습니다.

{% hint style="success" %}
다음은 유지하세요 [임시 파일용 스크래치 디스크의 bind-mount](/on-premises/ko/support/troubleshooting.md#running-overleaf-with-an-nfs-filesystem) 를 그대로 둡니다.
{% endhint %}

이제 인스턴스를 시작하고 마이그레이션을 검증할 수 있습니다:

* 편집기에서 바이너리 파일을 미리 볼 수 있음
* 이미지가 포함된 PDF를 컴파일할 수 있음
* 새 파일을 업로드할 수 있음

### 롤백

다음 단계를 역순으로 수행하여 마이그레이션을 원활하게 롤백할 수 있습니다:

1. 인스턴스 종료
2. source/destination 순서를 바꿔 파일을 다시 미러링
3. 역방향 변환을 사용하여 새 파일을 로컬 디렉터리에 다시 쓰기 `변환`
4. 이전 설정으로 인스턴스 재시작

{% code overflow="wrap" %}

```shell
# aws cli를 사용할 때
aws s3 sync s3://overleaf-user-files /srv/overleaf-s3-migration/user_files
aws s3 sync s3://overleaf-template-files /srv/overleaf-s3-migration/template_files
aws s3 sync s3://overleaf-project-blobs /srv/overleaf-bind-mount/data/history/overleaf-project-blobs
aws s3 sync s3://overleaf-chunks /srv/overleaf-bind-mount/data/history/overleaf-chunks

# minio mc를 사용할 때
mc mirror s3/overleaf-user-files /srv/overleaf-s3-migration/user_files
mc mirror s3/overleaf-template-files /srv/overleaf-s3-migration/template_files
mc mirror s3/overleaf-project-blobs /srv/overleaf-bind-mount/data/history/overleaf-project-blobs
mc mirror s3/overleaf-chunks /srv/overleaf-bind-mount/data/history/overleaf-chunks
```

{% endcode %}

```shell
# 로컬 Server CE/Server Pro에 파일 쓰기
tar --create --directory /srv/overleaf-s3-migration/user_files . \\
| docker exec --interactive sharelatex \\
    tar \\
      --extract \\
      --keep-old-files \\
      --directory /var/lib/overleaf/data/user_files \\
      --transform=sx./xx --transform=sx/x_x \\
      --wildcards '*/*/*'

tar --create --directory /srv/overleaf-s3-migration/template_files . \\
| docker exec --interactive sharelatex \\
    tar \\
      --extract \\
      --keep-old-files \\
      --directory /var/lib/overleaf/data/template_files \\
      --transform=sx./xx --transform=sx/x_xg \\
      --wildcards '*/*/*/*/pdf-converted-cache/*' \\
      --wildcards '*/*/*/*/pdf' \\
      --wildcards '*/*/*/*/zip'
```

{% hint style="info" %}
첫 번째 transform은 최상위 폴더를 제거합니다. 두 번째 transform은 디렉터리 구조를 평면 구조로 변경합니다. 와일드카드는 상위(프로젝트) 폴더가 아니라 파일만 추출되도록 보장합니다.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ayakaleaf-pro.ayaka.space/on-premises/ko/maintenance/s3-migration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
