All Products
Search
Document Center

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

Last Updated:Sep 03, 2025

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 permissions to a RAM user.

  • Differences between the sync and cp commands

    • The sync command supports the --delete option. This option deletes files that exist at the destination but not at the source. The cp command does not support the --delete option.

    • The sync command scans both the source and destination before it copies the files. The cp command scans the source and copies files at the same time.

    • The sync command can synchronize 2 million source files by default and a maximum of 5 million source files. The cp command has no limit on the number of source files.

Command format

ossutil sync file_url cloud_url

Parameter

Type

Description

file_url

string

The path of the on-premises folder to synchronize. For example, a path in Linux is /localfolder/, and a path in Windows is D:\localfolder\.

cloud_url

string

The path of the OSS folder. The path is in the format oss://bucketname/path/. For example, oss://examplebucket/exampledir/. If the cloud_url that you enter does not end with a forward slash (/), ossutil automatically adds a forward slash (/) to the end of the path.

--acl

string

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

  • private

  • public-read: Allows public read access.

  • public-read-write

  • default: The object inherits the ACL of the bucket.

--backup-dir

string

The directory to which backup files are stored.

--bigfile-threshold

int

The threshold to enable multipart upload, download, or copy for large files. The default value is 104857600 bytes.

--cache-control

string

Specifies the web page caching behavior when the object is downloaded.

--checkpoint-dir

string

The directory that stores checkpoint information for resumable operations. The default value is .ossutil_checkpoint/.

--checksum

/

Copies only source files whose sizes or checksums (if they exist) are different from the destination files. This option is valid only for object-to-object copy.

--content-disposition

string

Specifies how the object is displayed.

--content-encoding

string

Specifies the encoding format of the object.

--content-type

string

The content type of the object.

--copy-props

string

Specifies 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

/

Returns the files and subdirectories in the current directory instead of recursively displaying all files in all subdirectories.

--encoding-type

string

The encoding type of the object name or file name that you enter. Valid value: url.

--end-with

string

Returns objects that are alphabetically before or the same as the specified value.

--exclude

stringArray

The rules to exclude paths or file names.

--exclude-from

stringArray

Reads exclusion rules from a rule file.

--expires

string

Specifies the absolute expiration time of the cached content.

--files-from

stringArray

Reads the list of source file names from a file. Empty lines or commented lines are ignored.

--files-from-raw

stringArray

Reads the list of source file names from a file.

--filter

stringArray

The rules to filter paths or file names.

--filter-from

stringArray

Reads filtering rules from a rule file.

-f, --force

/

Forces the operation without a confirmation prompt.

--include

stringArray

The rules to include paths or file names.

--include-from

stringArray

Reads inclusion rules from a rule file.

-j, --job

int

The number of concurrent tasks for operations on multiple files. The default value is 3.

--list-objects

/

Uses the ListObjects operation to list objects.

--min-age

Duration

Transfers only files modified before the specified time interval. The default unit is seconds. You can use a unit suffix, such as 1h for 1 hour.

Note

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

--max-age

Duration

Transfers only files modified within the specified time interval. The default unit is seconds. You can use a unit suffix, such as 1h for 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. The time must be in UTC format. For example, 2006-01-02T15:04:05.

Note

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

--max-mtime

Time

Transfers only files modified before the specified time. The time must be in UTC format. For example, 2006-01-02T15:04:05.

--max-size

SizeSuffix

The maximum size of files to transfer. The default unit is byte. You can use a unit suffix, such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B.

--max-sync-num

int

The maximum number of files or objects to synchronize. The default value is 2000000. The value cannot be greater than 5000000.

--metadata

strings

Specifies the user metadata of the object. Use the key=value format.

--metadata-directive

string

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

  • COPY

  • REPLACE

--metadata-exclude

stringArray

The rules to exclude object metadata.

--metadata-filter

stringArray

The rules to filter object metadata.

--metadata-filter-from

stringArray

Reads object metadata filtering rules from a rule file.

--metadata-include

stringArray

The rules to include object metadata.

--min-size

SizeSuffix

The minimum size of files to transfer. The default unit is byte. You can use a unit suffix, such as B, K, M, G, T, or P. 1 K (KiB) = 1024 B.

--no-progress

/

Does not display the progress bar.

--page-size

int

The maximum number of objects to list per page in a batch operation. The default value is 1000. The value ranges from 1 to 1000.

--parallel

int

The number of concurrent tasks for operations within a single file.

--part-size

SizeSuffix

The part size. By default, ossutil calculates an appropriate part size based on the file size. The value ranges from 100 KiB to 5 GiB.

-r, --recursive

/

Performs the operation recursively. If you specify this option, the command is applied to all matching objects in the bucket. Otherwise, the command is applied only to the object specified by the path.

--request-payer

string

The payment method for the request. Set this parameter if you use the pay-by-requester mode. Valid value: requester.

--size-only

/

Copies only source files whose sizes are different from the destination files.

--start-after

string

Returns objects that are alphabetically after the specified value.

--storage-class

string

The storage class of the object. Valid values:

  • Standard: Provides standard storage.

  • IA is the Infrequent Access storage class.

  • Archive refers to Archive Storage.

  • ColdArchive

  • DeepColdArchive represents Deep Cold Archive.

--tagging

strings

Specifies the tags of the object. Use the key=value format.

--tagging-directive

string

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

  • COPY

  • REPLACE

-u, --update

/

Copies only source files that are newer than the destination files.

--ignore-existing

/

Skips destination files that already exist.

Note

For more information, see Command-line options.

Examples

  • Synchronize the on-premises localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/
  • Synchronize the .txt files in the on-premises localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/ --include "*.txt"
  • Synchronize all files except .txt files from the on-premises localfolder folder to OSS.

    ossutil sync D:/localfolder/ oss://examplebucket/destfolder/ --exclude "*.txt"
  • Synchronize an on-premises folder to OSS and delete files that exist in the specified OSS path but not in the on-premises folder.

    Add the --delete option to delete files that exist at the destination but not at the source. This action retains only the files from the current synchronization.

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