All Products
Search
Document Center

Object Storage Service:sync (Synchronize OSS objects to a local computer)

Last Updated:May 27, 2026

The sync command synchronizes objects from an OSS directory to a local directory.

Usage notes

  • Binary name

    For ossutil 1.6.16 and later, you can use ossutil directly as the binary name in the command line. You do not need to update the binary name based on the operating system. If you use a version of ossutil earlier than 1.6.16, update the binary name based on your operating system. For more information, see ossutil command reference.

  • Number of objects

    Without --delete, the number of objects is unlimited. With --delete, you can synchronize up to 1 million objects at a time. Exceeding this limit returns the over max sync numbers 1000000. error.

  • Differences from the cp command

    • The sync command recursively traverses all objects and subdirectories by default. The cp command requires the -r option for recursive operations.

    • The sync command supports --backup-dir to save destination-only files to a backup folder. The cp command does not support --backup-dir.

    • The sync command does not support --version-id, so it cannot synchronize previous versions of objects. The cp command supports --version-id.

    The sync and cp commands share all other options. cp (Download files).

Command format

ossutil sync cloud_url  file_url
[-f --force]
[-u --update]
[--maxdownspeed <value>]
[--delete]
[--backup-dir <value>]
[--enable-symlink-dir]
[--disable-all-symlink]
[--disable-ignore-error]
[--only-current-dir]
[--output-dir <value>]
[--bigfile-threshold <value>]
[--part-size <value>]
[--checkpoint-dir <value>]
[--range <value>]
[--encoding-type <value>]
[--snapshot-path <value>]
[--include <value>]
[--exclude <value>]
[--disable-crc64]
[--payer <value>]
[-j, --job <value>]
[--parallel <value>]
[--retry-times <value>]

Parameters and options:

Parameter or option

Description

cloud_url

The source OSS directory path in oss://bucketname/path/ format. Example: oss://examplebucket/exampledir/. If cloud_url does not end with a forward slash (/), ossutil appends one automatically.

file_url

The local destination folder path. Example: /localfolder/ (Linux) or D:\\localfolder\\ (Windows).

-f --force

Forces the operation without a confirmation prompt.

-u, --update

Synchronizes only when the destination file is missing or the source object is newer.

--maxdownspeed

Maximum download speed in KB/s. Default: 0 (unlimited).

--delete

Deletes destination files that do not exist in the source OSS directory.

Warning

Enable versioning before using --delete to prevent accidental data loss.

--backup-dir

Saves destination-only files to the specified backup folder instead of deleting them.

--enable-symlink-dir

Synchronizes linked subdirectories.

--disable-all-symlink

Ignores all symbolic links (files and directories) during synchronization.

--disable-ignore-error

Stops on errors during batch operations instead of ignoring them.

--only-current-dir

Synchronizes only objects in the current directory, excluding subdirectories.

--output-dir

The directory for error report files generated during batch synchronization.

Default: ossutil_output in the current directory.

--bigfile-threshold

Size threshold for resumable download, in bytes.

Default value: 100 MB

Value range: 0 to 9223372036854775807

--part-size

Part size in bytes. By default, ossutil calculates the part size based on the object size.

Value range: 1 to 9223372036854775807

--checkpoint-dir

The directory for resumable download checkpoint data. If a resumable download fails, ossutil creates a .ossutil_checkpoint directory to record checkpoint information. This directory is deleted after a successful download. If you specify a custom directory, ensure it can be deleted.

--range

Downloads the specified byte range from the object and saves it as a new file. Uses zero-based numbering.

  • Specify a range

    For example, 3-9 downloads from the 3rd byte to the 9th byte (inclusive).

  • Specify a start position

    For example, 3- downloads from the 3rd byte to the end of the file.

  • Specify an end position

    For example, -9 downloads from the start of the file to the 9th byte (inclusive).

--encoding-type

Encoding method for object names. Valid value: url. Default: no encoding.

--snapshot-path

The directory for synchronization snapshots. ossutil reads snapshots from this directory to perform incremental synchronization on subsequent runs.

--include

Includes only objects that match the specified pattern.

For more information, see --include and --exclude options.

--exclude

Excludes objects that match the specified pattern.

For more information, see --include and --exclude options.

--disable-crc64

Disables CRC-64 data validation.

--payer

Request payer. Set to requester to charge the requester for traffic and request fees.

-j, --job

Number of concurrent tasks for multi-object operations. Default: 3. Range: 1 to 10000.

--parallel

Number of concurrent tasks for single-object operations. Range: 1 to 10000. By default, ossutil determines the value based on the operation type and object size.

--retry-times

Number of retries on error. Default: 10. Range: 1 to 500.

Verify sync results

Verify that all objects were transferred correctly:

  • Check file count

    Compare object counts between OSS and local directories:

    # Count files in the local directory.
    ls -1 /local/dir/ | wc -l
    
    # Count objects in the OSS directory.  
    ossutil ls oss://bucket/dir/ -r | grep "^oss://" | wc -l
  • List synchronized objects

    Review the synchronized objects:

    # List local files with sizes.
    ls -lh /local/dir/
    
    # Compare with the OSS directory.
    ossutil ls oss://bucket/dir/ -r

Examples

The following examples use this file structure. The OSS bucket localdir folder contains a.txt, b.txt, and subdirectory C. The local destdir folder contains d.txt:

examplebucket           local root directory
└── localdir/             └── destdir/
       ├── a.txt                └── d.txt
       ├── b.txt
       └── C/
  • Synchronize the localdir folder from OSS to your local computer

    ossutil sync  oss://examplebucket/localdir/  destdir/ 

    Result: a.txt, b.txt, and subdirectory C are added to the local destdir folder.

    examplebucket           local root directory
    └── localdir/             └── destdir/
           ├── a.txt                ├── a.txt 
           ├── b.txt                ├── b.txt
           └── C/                   ├── d.txt
                                       └── C/ 
  • Synchronize with --backup-dir: sync localdir from examplebucket to local destdir, and move destination-only files to the backup folder.

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

    Result: the localdir folder is synchronized. Files in destdir but not in the source are moved to the backup folder. The local destdir contains only a.txt, b.txt, and subdirectory C. The original d.txt is moved to the backup folder.

    examplebucket              local root directory
    └── localdir/               ├── destdir/
           ├── a.txt            │     ├── a.txt 
           ├── b.txt            │     ├── b.txt
           └── C/               │     └── C/                             
                                   └── backup/
                                          └──d.txt
  • Successful synchronization output:

    Succeed: Total num: 2, size: 750,081. OK num: 2(upload 2 files).
    
    average speed 1641000(byte/s)

Common options

To access a bucket in a different region, use -e to specify the endpoint. To access a bucket owned by a different Alibaba Cloud account, use -i for the AccessKey ID and -k for the AccessKey secret.

Example: synchronize from a bucket in the China (Shanghai) region owned by another Alibaba Cloud account:

ossutil sync oss://examplebucket/srcfolder/  examplefolder/ -e oss-cn-shanghai.aliyuncs.com -i yourAccessKeyID -k yourAccessKeySecret

Common options.