sync

Prev Next

Classic/VPC 환경에서 이용 가능합니다.

Object Storage 버킷 간 또는 버킷과 로컬 디렉터리 간에 폴더와 객체를 동기화합니다

구문

sync 구문은 다음과 같습니다.

aws s3 sync \
    <source> \
    <destination> \
    [--dryrun] \
    [--quiet] \
    [--include <pattern>] \
    [--exclude <pattern>] \
    [--acl <acl>] \
    [--follow-symlinks | --no-follow-symlinks] \
    [--no-guess-mime-type] \
    [--content-type <content-type>] \
    [--only-show-errors] \
    [--no-progress] \
    [--page-size <page-size>] \
    [--metadata <metadata>] \
    [--metadata-directive <COPY|REPLACE>] \
    [--size-only] \
    [--exact-timestamps] \
    [--delete] \
    --endpoint-url <endpoint-url>

옵션

sync 실행 시 지정할 수 있는 옵션을 설명합니다.

필수 옵션

sync의 필수 옵션입니다.

옵션 타입 필수 여부 설명
<source> String Required 원본 경로
  • 로컬 디렉터리 또는 s3://{bucket_name}[/{prefix}] 형식의 S3 URI
<destination> String Required 대상 경로
  • 로컬 디렉터리 또는 s3://{bucket_name}[/{prefix}] 형식의 S3 URI

선택 옵션

sync의 선택 옵션입니다. 지정하지 않은 옵션에는 기본값이 적용됩니다.

옵션 타입 필수 여부 설명
--dryrun Boolean Optional 명령을 실제로 실행하지 않고 수행 결과만 확인
--quiet Boolean Optional 응답 결과 미표시
--include String Optional 지정한 패턴과 일치하는 객체만 명령에 포함
  • 지정한 순서대로 적용
--exclude String Optional 지정한 패턴과 일치하는 객체를 명령에서 제외
  • 지정한 순서대로 적용
--follow-symlinks, --no-follow-symlinks Boolean Optional 심볼릭 링크가 가리키는 파일의 콘텐츠 업로드 여부
  • 기본값: --follow-symlinks
  • 로컬 파일 시스템에서 객체를 업로드하는 경우에만 해당
--no-guess-mime-type Boolean Optional 업로드할 객체의 콘텐츠 유형 자동 추측 비활성화
--acl String Optional 객체에 적용할 접근 제어 목록
  • private | public-read | public-read-write | authenticated-read
--content-type String Optional 명시적인 콘텐츠 유형 정의
--only-show-errors Boolean Optional 에러만 표시하고 다른 응답값은 미표시
--no-progress Boolean Optional 파일 전송 진행률 미표시
  • --quiet 또는 --only-show-errors가 지정된 경우, 미적용
--page-size Integer Optional 페이지당 항목 수
  • 1~1000
--metadata String Optional 객체와 함께 저장할 메타데이터 설정
--metadata-directive String Optional 동기화 시 메타데이터 처리 방식
  • COPY (기본값) | REPLACE
    • COPY: 원본 복사
    • REPLACE: 재정의
--size-only Boolean Optional 객체 크기만을 기준으로 동기화 여부 결정
--exact-timestamps Boolean Optional 크기가 같은 객체는 타임스탬프가 정확히 일치하는 경우에만 동기화 대상에서 제외
  • Object Storage에서 로컬로 동기화하는 경우에만 적용
--delete Boolean Optional 원본에는 없고 대상 경로에만 있는 객체 삭제

공통 옵션

aws 명령에서 공통으로 사용하는 옵션에 대한 정보는 Object Storage 옵션을 참조해 주십시오.

예시

요청이 성공하면 동기화된 객체의 원본 경로와 대상 경로가 출력됩니다.

명령

버킷의 객체를 로컬 디렉터리로 동기화하는 명령 예시는 다음과 같습니다.

aws s3 sync s3://my-test-bucket ./local-dir \
    --endpoint-url=https://kr.object.ncloudstorage.com

로컬 디렉터리의 파일을 버킷으로 동기화하는 명령 예시는 다음과 같습니다.

aws s3 sync ./local-dir s3://my-test-bucket \
    --endpoint-url=https://kr.object.ncloudstorage.com

버킷의 객체를 다른 버킷으로 동기화하면서 원본에 없는 파일을 삭제하는 명령 예시는 다음과 같습니다.

aws s3 sync s3://my-test-bucket s3://my-backup-bucket \
    --delete \
    --endpoint-url=https://kr.object.ncloudstorage.com
참고

awscli 2 버전에서는 동기화 명령 실행 시 지원하지 않는 API를 호출하여 오류가 발생할 수 있으므로 1.15.x 버전 사용을 권장합니다.

출력

버킷의 객체를 로컬 디렉터리로 동기화하는 출력 예시는 다음과 같습니다.

Completed 87 Bytes/87 Bytes (1012 Bytes/s) with 2 file(s) remaining
download: s3://my-test-bucket/sample.txt to local-dir/sample.txt
Completed 87 Bytes/87 Bytes (1012 Bytes/s) with 1 file(s) remaining
download: s3://my-test-bucket/docs/report.txt to local-dir/docs/report.txt

로컬 디렉터리의 파일을 버킷으로 동기화하는 출력 예시는 다음과 같습니다.

Completed 24 Bytes/24 Bytes (613 Bytes/s) with 1 file(s) remaining
upload: local-dir/notes.txt to s3://my-test-bucket/notes.txt

버킷의 객체를 다른 버킷으로 동기화하면서 원본에 없는 파일을 삭제한 출력 예시는 다음과 같습니다.

delete: s3://my-backup-bucket/obsolete.txt