> For the complete documentation index, see [llms.txt](https://overleaf-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://overleaf-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" %}
히스토리 디렉터리는 이미 올바른 레이아웃을 가지고 있습니다. 추가 디스크 공간이 필요 없는 바인드 마운트된 소스 폴더에서 직접 업로드할 수 있습니다.
{% 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단계: 파일 업로드

선호에 따라 minio mc S3 클라이언트나 aws cli를 사용하여 파일을 S3 호환 객체 저장소에 업로드할 수 있습니다.

**aws cli**

{% hint style="info" %}

* 여기서 다음을 바꿔야 합니다 `overleaf-user-files`, `overleaf-template-files`, `overleaf-project-blobs` 그리고 `overleaf-chunks` 를 S3 버킷 이름으로.
* 또한 다음도 바꾸세요 `/srv/overleaf-bind-mount` 의 로컬 경로로 `/var/lib/overleaf` 바인드 마운트입니다. 기본값은 `~/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를 가리키도록 인스턴스 시작

개요의 변수 섹션에 자세히 설명된 대로, 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 섹션에서 데이터 디렉터리의 바인드 마운트도 제거할 수 있습니다.

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

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

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

### 롤백

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

1. 인스턴스를 종료하세요
2. 원본/대상 순서를 바꿔 파일을 다시 미러링하세요
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" %}
첫 번째 변환은 최상위 폴더를 제거합니다. 두 번째 변환은 디렉터리 레이아웃을 평면 구조로 바꿉니다. 와일드카드는 상위(프로젝트) 폴더가 아니라 파일만 추출되도록 보장합니다.
{% 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://overleaf-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.
