All Products
Search
Document Center

Object Storage Service:sync (synchronize local files to OSS)

Last Updated:Jun 13, 2026

The sync command synchronizes local files to OSS.

Notes

  • To synchronize local files to OSS, you must have the oss:PutObject, oss:ListObjects, and oss:DeleteObject permissions. For more information, see Grant custom access policies to Resource Access Management (RAM) users.

  • Differences between the sync and cp commands

    • When using the sync command to synchronize data to OSS, ossutil supports the --delete option to delete files that exist at the destination but not at the source, keeping only the files synchronized in this operation. The cp command does not support the --delete option.

    • The sync command scans both the source and destination before copying. The cp command scans the source and copies files simultaneously.

    • By default, sync supports up to 2 million source files, with a maximum of 5 million. The cp command has no limit on the number of source files.

  • When using the -u, --update option, the system sends at least one HEAD request for each file to compare it, regardless of whether the target file exists. In scenarios where few files change, this generates many inefficient requests, which may reduce performance and incur extra request charges. Evaluate your actual business needs carefully before using this option to avoid unnecessary resource consumption.

Command syntax

ossutil sync file_url cloud_url

Parameter

Type

Description

file_url

string

Path of the local folder to synchronize. Examples: Linux system path /localfolder/, Windows system path D:\localfolder\.

cloud_url

string

OSS folder path. Format: oss://bucketname/path/. Example: oss://examplebucket/exampledir/. If the specified cloud_url does not end with a forward slash (/), ossutil automatically appends one.

--acl

string

Access permissions for the object. Valid values:

  • private: private.

  • public-read: public read.

  • public-read-write: public read and write.

  • default: inherit from the bucket.

--backup-dir

string

Directory for backup files.

--bigfile-threshold

int

Threshold to enable multipart upload, download, or copy for large files (default value: 104857600).

--cache-control

string

Specifies caching behavior when the object is downloaded by a web browser.

--checkpoint-dir

string

Directory for resumable transfer checkpoint data (default value: .ossutil_checkpoint/).

--checksum

/

Copies only source files whose size or checksum (if available) differs from the destination. Applies only to object-to-object copy operations.

--content-disposition

string

Specifies how the object is displayed.

--content-encoding

string

Declares the encoding method of the object.

--content-type

string

Content type of the object.

--copy-props

string

Determines which properties to copy from the source object. Valid values:

  • none

  • metadata

  • default

--delete

/

Deletes files that exist at the destination but not at the source.

-d, --dirs

/

Lists files and subdirectories in the current directory without recursively listing all files in subdirectories.

--encoding-type

string

Encoding method for input object names or file names. Valid value: url.

--end-with

string

Returns objects that come before or match the specified value in alphabetical order.

--exclude

stringArray

Exclusion rules for paths or file names.

--exclude-from

stringArray

Reads exclusion rules from a rule file.

--expires

string

Specifies the absolute expiration time for cached content.

--files-from

stringArray

Reads a list of source file names from a file, ignoring empty or comment lines.

--files-from-raw

stringArray

Reads a list of source file names from a file.

--filter

stringArray

Filtering rules for paths or file names.

--filter-from

stringArray

Reads filtering rules from a rule file.

-f, --force

/

Forces the operation without prompting for confirmation.

--include

stringArray

Inclusion rules for paths or file names.

--include-from

stringArray

Reads inclusion rules from a rule file.

-j, --job

int

Number of concurrent tasks for multi-file operations (default value: 3).

--list-objects

/

Uses the ListObjects API to list objects.

--min-age

Duration

Transfers only files modified before the specified time interval. The default unit is seconds. You can use suffixes such as h for hours. Example: 1h means 1 hour.

Note

--min-age 1h transfers only files modified one hour ago or earlier.

--max-age

Duration

Transfers only files modified within the specified time interval. The default unit is seconds. You can use suffixes such as h for hours. Example: 1h means 1 hour.

Note

--max-age 1h transfers only files modified within the last hour.

--min-mtime

Time

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

Note

--min-mtime "2006-01-02T15:04:05" transfers only files modified after January 2, 2006, at 15:04:05.

--max-mtime

Time

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

--max-size

SizeSuffix

Limits the maximum file size to transfer. The default unit is bytes. You can use suffixes B|K|M|G|T|P, where 1K (KiB) = 1024B.

--max-sync-num

int

Maximum number of files or objects to synchronize (default value: 2000000). Maximum allowed value: 5000000.

--metadata

strings

Specifies user-defined metadata for the object in key=value format.

--metadata-directive

string

Specifies how to set metadata for the destination object. Valid values:

  • COPY

  • REPLACE

--metadata-exclude

stringArray

Exclusion rules for object metadata.

--metadata-filter

stringArray

Filtering rules for object metadata.

--metadata-filter-from

stringArray

Reads object metadata filtering rules from a rule file.

--metadata-include

stringArray

Inclusion rules for object metadata.

--min-size

SizeSuffix

Limits the minimum file size to transfer. The default unit is bytes. You can use suffixes B|K|M|G|T|P, where 1K (KiB) = 1024B.

--no-progress

/

Does not display the progress bar.

--page-size

int

Maximum number of objects listed per page during batch operations (default value: 1000). Valid range: 1 to 1000.

--parallel

int

Number of concurrent tasks for internal operations on a single file.

--part-size

SizeSuffix

Part size for multipart operations. By default, ossutil calculates an appropriate part size based on the file size. Valid range: 100 KiB to 5 GiB.

-r, --recursive

/

Performs operations recursively. When this option is specified, the command operates on all matching objects in the bucket. Otherwise, it operates only on objects at the specified path.

--request-payer

string

Payment method for the request. Set this parameter if the bucket uses pay-by-requester mode. Valid value: requester.

--size-only

/

Copies only source files whose size differs from the destination.

--start-after

string

Returns objects that come after the specified value in alphabetical order, excluding the specified value.

--storage-class

string

Storage class of the object. Valid values:

  • Standard: Standard storage.

  • IA: Infrequent Access (IA) storage class.

  • Archive: Archive Storage.

  • ColdArchive: Cold Archive.

  • DeepColdArchive: Deep Cold Archive.

--tagging

strings

Specifies tags for the object in key=value format.

--tagging-directive

string

Specifies how to set tags for the destination object. Valid values:

  • COPY

  • REPLACE

-u, --update

/

Skip files at the destination that already exist and have a newer modification time than the source files.

Note

If a file already exists at the destination but has an older modification time than the source file, the file will be updated.

--ignore-existing

/

Skip files that already exist at the destination.

Note

Starting from ossutil 2.3.0, the --job, --parallel, --bigfile-threshold, --part-size, and --write-buffer-size options can be configured through a configuration file. Append them in key=value format under the corresponding profile section in the configuration file (for example, job=10), or write them using ossutil config set. Command-line options take precedence over configuration file settings.

Note

For more information, see Command-line options.

Examples

  • Synchronize the local localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/
  • Synchronize .txt files from the local localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/ --include "*.txt"
  • Synchronize non-.txt files from the local localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/ --exclude "*.txt"
  • Synchronize a local folder to OSS and delete files at the OSS destination path that do not exist locally.

    Add the --delete option to remove files that exist at the destination but not at the source, keeping only the files synchronized in this operation.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/ --delete