All Products
Search
Document Center

Object Storage Service:cp (copy objects)

Last Updated:Jun 13, 2026

Copying an object duplicates a file from a source bucket to a destination bucket within the same region or to another directory in the same bucket without altering the file content. You can use the cp command in ossutil to perform this operation.

Important notes

  • To copy objects, you must have the oss:GetObject, oss:ListObjects, and oss:PutObject permissions. For more information, see Grant custom permission policies to RAM users.

  • Only complete objects can be copied. Unmerged multipart uploads are not supported.

  • By default, both tags and object attributes are copied. Use the --copy-props option to control how attributes and tags are handled during copying.

  • Cross-account and cross-region copying is not supported. To migrate files across accounts or regions, use ossimport or Data Online Migration.

  • When using the -u, --update option, the system sends at least one HEAD request per file to compare timestamps—even if the destination file does not exist. In scenarios with few data changes, this generates many inefficient requests, which may reduce performance and incur extra request charges. Evaluate your specific use case carefully before enabling this option to avoid unnecessary resource consumption.

Command syntax

ossutil cp oss://src_bucket[/src_prefix] oss://dest_bucket[/dest_prefix] [flags]

Parameter

Type

Description

src_bucket

string

Name of the source bucket.

src_prefix

string

A directory path or prefix within the source bucket.

dest_bucket

string

Name of the destination bucket.

dest_prefix

string

A directory path or prefix within the destination bucket.

--acl

string

Access control level for the object. Valid values:

  • private: private.

  • public-read: Public read access.

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

  • Default: inherit bucket.

--bandwidth-limit

SizeSuffix

Limits network bandwidth to control data transfer speed. Minimum value is 1024 B/s. The default unit is B/s.

You can specify a unit when setting this parameter. Supported units include B (bytes), K (kilobytes), M (megabytes), and G (gigabytes). For example, 50 M sets the limit to 50 MB/s.

--bigfile-threshold

SizeSuffix

Threshold (in bytes) to enable multipart upload, download, or copy for large files. Default value: 104857600 (100 MiB).

--cache-control

string

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

--checkers

int

Number of concurrent checker threads. Default: 16.

--checkpoint-dir

string

Directory for storing checkpoint data to support resumable transfers. Default: .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 the display format of the object.

--content-encoding

string

Declares the encoding method used for the object.

--content-type

string

MIME type of the object.

--copy-props

string

Controls how object properties and tags are copied during object-to-object operations. Supported values:

  • default (default): Copies both object properties and tags. Object properties include content-type, content-language, content-encoding, content-disposition, cache-control, expires, and metadata (custom user metadata).

  • metadata: Copies only object properties.

  • none: Copies only the object data, ignoring properties and tags.

-d, --dirs

string

Processes files and immediate subdirectories in the current directory, without recursively traversing deeper subdirectories.

--encoding-type

string

Encoding type for input object 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 filenames.

--exclude-from

stringArray

Reads exclusion rules from a file.

--expires

string

Sets an absolute expiration time for cached content.

--files-from

stringArray

Reads a list of source filenames from a file, skipping empty or commented lines. Applies only in filtering scenarios.

--files-from-raw

stringArray

Reads a list of source filenames from a file. Applies only in filtering scenarios.

--filter

stringArray

Filtering rules for paths or filenames.

--filter-from

stringArray

Reads filtering rules from a file.

-f, --force

/

Forces the operation without prompting for confirmation.

--ignore-existing

/

Skips files that already exist at the destination.

--include

stringArray

Inclusion rules for paths or filenames.

--include-from

stringArray

Reads inclusion rules from a file.

-j, --job

int

Number of concurrent jobs. Default: 3.

Note

This option takes effect only when used with one of the following flags: -f, --update, --size-only, or --ignore-existing.

--list-objects

/

Uses the ListObjects API to enumerate objects.

--max-size

SizeSuffix

Maximum file size to transfer. Default unit is bytes. You can append a suffix: B|K|M|G|T|P (e.g., 1K = 1024 B).

--metadata

strings

User-defined metadata for the object, specified as key=value pairs.

--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 metadata filtering rules from a file.

--metadata-include

stringArray

Inclusion rules for object metadata.

--min-age

Duration

Copies only files modified before the specified time interval. Default unit is seconds. You can use suffixes like h (hours). Example: 1h means 1 hour.

Note

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

--max-age

Duration

Copies only files modified within the specified time interval. Default unit is seconds. You can use suffixes like h (hours). Example: 1h means 1 hour.

Note

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

--min-mtime

Time

Copies only files modified after the specified time. Time format: UTC (e.g., 2006-01-02T15:04:05).

Note

--min-mtime "2006-01-02T15:04:05" copies only files modified after 2006-01-02T15:04:05.

--max-mtime

Time

Copies only files modified before the specified time. Time format: UTC (e.g., 2006-01-02T15:04:05).

--min-size

SizeSuffix

Minimum file size to transfer. Default unit is bytes. You can append a suffix: B|K|M|G|T|P (e.g., 1K = 1024 B).

--no-progress

/

Disables the progress bar.

--no-error-report

/

Prevents generation of error report files during batch operations.

--output-dir

string

Directory where error report files are saved during batch operations. Default: ossutil_output.

--page-size

int

Maximum number of objects listed per page during batch copy. Valid range: 1–1000. Default: 1000.

--parallel

int

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

--part-size

SizeSuffix

Size of each part in multipart operations. By default, ossutil calculates an optimal part size based on file size. Valid range: 100 KiB to 5 GiB.

-r, --recursive

/

Performs the operation recursively. When this option is set, the command processes all matching objects in the bucket. Otherwise, it operates only on the explicitly specified object.

--request-payer

string

Payment method for the request. Set this to requester if the bucket uses pay-by-requester mode.

--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 value itself.

--storage-class

string

Storage class for the object. Valid values:

  • Standard: Standard storage.

  • IA: Infrequent access storage.

  • Archive: Archive Storage.

  • ColdArchive: Cold Archive storage.

  • DeepColdArchive: Deep Cold Archive storage.

--tagging

string

Tags for the object, specified as key=value pairs.

--tagging-directive

string

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

  • COPY

  • REPLACE

-u, --update

/

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

Note

If the destination file exists but has an older modification time than the source, the file is updated.

--version-id

string

Specify the object's version ID (VersionId).

Note

Starting with ossutil version 2.3.0, you can configure the options --job, --parallel, --bigfile-threshold, --part-size, and --write-buffer-size in a configuration file. Add them as key=value entries under the relevant profile section (for example, job=10), or use the ossutil config set command. Command-line options override settings in the configuration file.

Note

For more information, see Command-line options.

Destination object naming rules:

  • For single-file copy, if dest_prefix is empty, the destination object name matches the source file’s relative path.

  • For single-file copy, if dest_prefix ends with "/", the destination object name is dest_prefix + source relative path.

  • For single-file copy, if dest_prefix does not end with "/", the destination object name matches dest_prefix.

  • For batch copy, if dest_prefix ends with "/", the destination object name is dest_prefix + source relative path.

  • For batch copy, if dest_prefix does not end with "/", the destination object name is dest_prefix + "/" + source relative path.

Examples

  • Copy a single file

    ossutil cp oss://examplebucket1/examplefile.txt oss://examplebucket1/desfolder/
  • Copy incremental files

    During batch copy, use the --update option to skip files at the destination that already exist and have a newer modification time than the source:

    ossutil cp oss://examplebucket1/srcfolder1/ oss://examplebucket1/desfolder/ -r --update
  • Bucket-to-bucket copy after same-region replication

    • Use the --checksum option for checksum-based incremental copy: Ideal when strict content consistency is required (e.g., retrying a failed batch copy while skipping successfully copied files). The system follows this logic:

      1. Compare file sizes first.

      2. If sizes match, compute and compare CRC64 checksums.

      3. Copy only if checksums differ.

      ossutil cp oss://examplebucket1/srcfolder1/ oss://examplebucket1/desfolder/ -r --checksum
    • Use the --ignore-existing option to skip existing files: Useful when you want to skip files that already exist at the destination without overwriting them:

      ossutil cp oss://examplebucket1/srcfolder1/ oss://examplebucket1/desfolder/ -r --ignore-existing
  • Rename a file

    ossutil cp oss://examplebucket1/examplefile.txt oss://examplebucket1/example.txt 

    When renaming a file with the cp command, the original file remains. Delete it manually after renaming if needed.

  • Modify object tags

    ossutil cp oss://examplebucket1/examplefile.txt oss://examplebucket1/ --tagging "abc=1&bcd=2&……"