sync

Prev Next

Available in Classic and VPC

Sync folders and objects between Object Storage buckets or between a bucket and a local directory.

Syntax

The sync syntax is as follows:

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>

Options

This section describes the options available when running sync.

Required options

The following options are required for sync.

Options Type Required Description
<source> String Required Source path
  • Local directory or S3 URI in the format of s3://{bucket_name}[/{prefix}]
<destination> String Required Destination path
  • Local directory or S3 URI in the format of s3://{bucket_name}[/{prefix}]

Optional options

These are the optional options for sync. Options that are not specified will use their default values.

Options Type Required Description
--dryrun Boolean Optional Checks the results of the command without actually executing it.
--quiet Boolean Optional Does not display the response.
--include String Optional Includes only objects matching the specified pattern in the command.
  • Applied in the specified order.
--exclude String Optional Excludes objects matching the specified pattern from the command.
  • Applied in the specified order.
--follow-symlinks, --no-follow-symlinks Boolean Optional Whether to upload the content of files pointed to by symbolic links
  • Default: --follow-symlinks
  • Applies only when uploading objects from the local file system.
--no-guess-mime-type Boolean Optional Disables automatic guessing of the content type for objects to be uploaded.
--acl String Optional List of access controls to apply to the object
  • private | public-read | public-read-write | authenticated-read
--content-type String Optional Define explicit content type.
--only-show-errors Boolean Optional Displays only errors; other response values are not displayed.
--no-progress Boolean Optional Does not display file transfer progress
  • Not applied if --quiet or --only-show-errors is specified
--page-size Integer Optional Number of items per page
  • 1-1000
--metadata String Optional Set up metadata to store with the object.
--metadata-directive String Optional Metadata handling method during sync
  • COPY (default) | REPLACE
    • COPY: Copies original.
    • REPLACE: Redefines.
--size-only Boolean Optional Determines whether to sync based solely on object size.
--exact-timestamps Boolean Optional Excludes objects of the same size from sync only if their timestamps match exactly.
  • Applies only when syncing from Object Storage to a local location.
--delete Boolean Optional Deletes objects that exist only in the destination path and not in the source.

Common options

For information about the options common to all aws subcommands, see Object Storage options.

Examples

If the request is successful, the source and destination paths of the synced object are displayed.

Command

The following is an example command for syncing objects from a bucket to a local directory.

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

The following is an example command for syncing files from a local directory to a bucket.

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

The following is an example command for syncing objects from a bucket to another bucket while deleting files that do not exist in the source.

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

In AWS CLI version 2, errors may occur when running the sync command because it calls unsupported APIs; therefore, we recommend using version 1.15.x.

Output

The following is an example output of syncing objects from a bucket to a local directory.

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

The following is an example output for syncing files from a local directory to a bucket.

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

The following is an example output for syncing objects from one bucket to another and deleting files that do not exist in the source.

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