All Products
Search
Document Center

Object Storage Service:sync (synchronize files between OSS)

Last Updated:May 15, 2025

You can use the sync command to batch synchronize objects from a folder in a bucket to another bucket within the same region.

Considerations

  • To synchronize files between OSS buckets, you must have the oss:GetObject, oss:ListObjects, oss:PutObject, and oss:DeleteObject permissions. For more information, see Grant custom permissions to a RAM user.

  • You cannot use the sync command to synchronize Cold Archive or Deep Cold Archive objects from a source bucket to a destination bucket.

Command syntax

ossutil sync cloud_url cloud_url

Parameter

Type

Description

cloud_url

string

The source path and destination path. The format is oss://bucketname/path/. For example, to synchronize the srcdir folder to the destdir folder in the examplebucket bucket, specify the source path as oss://examplebucket/srcdir/ and the destination path as oss://examplebucket/destcdir/.

Important

If the cloud_url that you enter does not end with a forward slash (/), ossutil automatically adds a forward slash (/) to the end.

--acl

string

The access control list (ACL) of the object. Valid values:

  • private: The ACL is private.

  • public-read: The ACL is public-read.

  • public-read-write: The ACL is public-read-write.

  • default: The ACL of the object is the same as that of the bucket in which the object is stored.

--backup-dir

string

The backup directory.

--bigfile-threshold

int

The object size threshold for multipart upload, download, and copy. Default value: 104857600.

--cache-control

string

The caching behavior in web browsers when the object is downloaded.

--checkpoint-dir

string

The directory in which the checkpoint information is stored. Default value: .ossutil_checkpoint/.

--checksum

/

Specifies that only when one of the following conditions is met, the source object is copied: a. the size of the source object is different from that of the destination object; b. the CRC-64 of the source object is different from that of the destination object, but the size of the source object is the same as that of the destination object. This parameter takes effect only for object copy operations.

--content-disposition

string

The display form of the object.

--content-encoding

string

The encoding method of the object.

--content-type

string

The content type of the object.

--copy-props

string

The attributes that you want to synchronize from the source object. Valid values:

  • none

  • metadata

  • default

--delete

/

Deletes objects that exist in the destination path but does not exist in the source path.

-d, --dirs

/

Lists objects and subdirectories in the current directory, instead of recursively displaying all objects in all subdirectories.

--encoding-type

string

The encoding method used to encode the object name. Valid value: url.

--end-with

string

Matches objects whose names are lexicographically before the specified value (inclusive).

--exclude

stringArray

The exclusion rules for paths or object names.

--exclude-from

stringArray

Reads exclusion rules from a file.

--expires

string

The absolute expiration time of the cached content.

--files-from

stringArray

Reads a list of source object names from a file, with empty lines and comment lines ignored.

--files-from-raw

stringArray

Reads a list of source objects from a file.

--filter

stringArray

The filter rule for paths or object names.

--filter-from

stringArray

Reads filter rules from a file.

-f, --force

/

Forces the operation without requiring user confirmation.

--include

stringArray

The inclusion rules for paths or object names.

--include-from

stringArray

Reads inclusion rules from a file.

-j, --job

int

The number of concurrent tasks that can be performed across multiple objects. Default value: 3.

--list-objects

/

Lists objects by calling the ListObjects operation.

--min-age

Duration

Transfers only files that were modified before the specified time interval. The default unit is seconds. You can use a unit suffix. For example, 1h indicates one hour.

Note

--min-age 1h indicates that only files that were modified 1 hour ago or earlier are transferred.

--max-age

Duration

Transfers only files that were modified within the specified time interval. The default unit is seconds. You can use a unit suffix. For example, 1h indicates one hour.

Note

--max-age 1h indicates that only files that were modified within the last hour are transferred.

--min-mtime

Time

Transfers only files that were modified after the specified time. The time format is UTC. Example: 2006-01-02T15:04:05.

Note

--min-mtime "2006-01-02T15:04:05" indicates that only files that were modified after January 2, 2006, 15:04:05 are transferred.

--max-mtime

Time

Transfers only files that were modified before the specified time. The time format is UTC. Example: 2006-01-02T15:04:05.

--max-size

SizeSuffix

The maximum size of a file or object that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--max-sync-num

int

The maximum number of files or objects. The default value is 2000000. The maximum value is 5000000.

--metadata

strings

The user metadata in key=value pairs.

--metadata-directive

string

The method used to configure the metadata of the object. Valid values:

  • COPY

  • REPLACE

--metadata-exclude

stringArray

The exclusion rule for object metadata.

--metadata-filter

stringArray

The filter rule for object metadata.

--metadata-filter-from

stringArray

Reads the metadata filter rule from a file.

--metadata-include

stringArray

The inclusion rule for object metadata.

--min-size

SizeSuffix

The minimum size of a file or object that can be transferred. By default, the size is in bytes (B). You can suffix the numerical value with a 1024-based unit: B for byte, K for Kibibyte, M for Mebibyte, G for Gibibyte, T for Tebibyte, or P for Pebibyte.

--no-progress

/

Does not display the progress bar.

--page-size

int

The maximum number of objects that can be returned per page. Default value: 1000. Valid values: 1 to 1000.

--parallel

int

The number of concurrent tasks for internal operations on a single object.

--part-size

SizeSuffix

The part size. By default, the part size is automatically calculated based on the file or object size. The part size ranges from 100 KiB to 5 GiB.

-r, --recursive

/

If this option is specified, the command performs the operation on all matching objects in the bucket. If this option is not specified, the command performs the operation only on the specified objects.

--request-payer

string

The payer of the request. If pay-by-requester is enabled, set this parameter to requester.

--size-only

/

Copies a source file or object only if it has a different file size from the destination object.

--start-after

string

Specifies that objects whose names are alphabetically after the value of the --start-after parameter are returned.

--storage-class

string

The storage class of the object. Valid values:

  • Standard: Standard storage class.

  • IA: Infrequent Access (IA)

  • Archive: Archive

  • ColdArchive: Cold Archive

  • DeepColdArchive: Deep Cold Archive

--tagging

strings

Specify tags in the format of key=value pairs.

--tagging-directive

string

The method used to set tags for the destination object. Valid values:

  • COPY

  • REPLACE

-u, --update

/

Copies a source file or object only if its last modified time is later than that of its destination object or file.

--ignore-existing

/

Ignores existing destination objects.

Note

For more information, see Command-line options.

References

  • Synchronize the exampledir folder in examplebucket1 to the srcdir folder.

    ossutil sync oss://examplebucket1/exampledir/  oss://examplebucket1/srcdir/
  • Synchronize the exampledir folder in examplebucket1 to the destdir folder in examplebucket2.

    ossutil sync oss://examplebucket1/exampledir/ oss://examplebucket2/destdir/
  • Use the --delete option to synchronize all files from examplebucket1 to examplebucket2, and delete files that exist in examplebucket2 but do not exist in examplebucket1.

    ossutil sync oss://examplebucket1 oss://examplebucket2 --delete