All Products
Search
Document Center

Object Storage Service:sync (synchronize OSS objects to your computer)

Last Updated:May 15, 2025

The sync command is used to synchronize objects from OSS to your computer.

Usage notes

To synchronize objects from OSS to your computer, you must have the oss:GetObject and oss:ListObjects permissions. For more information, see Grant custom permissions to a RAM user.

Command syntax

ossutil sync cloud_url  file_url

Parameter

Type

Description

cloud_url

string

The path of the directory in which the objects that you want to synchronize are stored. The format is oss://bucketname/path/. For example, oss://examplebucket/exampledir/. If the cloud_url that you specify does not end with a forward slash (/), ossutil automatically adds a forward slash (/) to the end of the path.

file_url

string

The path of the local directory to which you want to synchronize objects. For example, the path of a Linux file is /localfolder/, and the path of a Windows file is D:\localfolder\.

--acl

string

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

  • private: private

  • public-read: public-read

  • public-read-write: 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 specified directory for storing checkpoint information (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 data. 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 rule for paths or object names.

--exclude-from

stringArray

Reads the exclusion rule from a file.

--expires

string

The absolute expiration time of the cached content.

--files-from

stringArray

Reads a list of source objects 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 rule for paths or object names.

--include-from

stringArray

Reads the inclusion rule from a file.

-j, --job

int

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

--list-objects

/

Specifies that the ListObjects operation is called to list objects.

--min-age

Duration

Only transfers 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

Only transfers 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

Only transfers files that were modified after the specified time. The time format is UTC. For 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

Only transfers files that were modified before the specified time. The time format is UTC. For 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

/

Specifies recursion. 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 object only if it has a different 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

  • IA: Infrequent Access (IA)

  • Archive: Archive

  • ColdArchive: Cold Archive

  • DeepColdArchive: Deep Cold Archive

--tagging

strings

The tags of the object in 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 object only if its last modified time is later than that of its destination object.

--ignore-existing

/

Ignores existing destination objects.

Note

For more information, see Command-line options.

Examples

  • Synchronize the localdir folder from OSS to your computer.

    ossutil sync  oss://examplebucket/localdir/  D:\destdir\
  • Synchronize the localdir folder from the examplebucket bucket to the local destdir folder, and specify the backup folder by using the --backup-dir option to save files that exist in the local directory but do not exist in OSS. These files are deleted from the original folder.

    ossutil sync oss://examplebucket/localdir/  D:\destdir\  --delete  --backup-dir backup/