Files
doc-exports/docs/obs/tool-obsutil/obs_11_0053.html
weihongmin1 c4291b1dd5 OBS Util 0309 Verion
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2026-03-27 12:15:19 +00:00

39 KiB

Moving an Object

Function

You can use this command to move a single object or move objects in batches by a specified object name prefix.

  • Do not change the source objects in the OBS bucket when moving objects. Otherwise, the operation may fail or data may be inconsistent.
  • The source objects are deleted after the move operation succeeds.
  • If an object move (mv) task is manually canceled or interrupted unexpectedly, obsutil cannot automatically resume or continue the task. In such cases, the move task may fail to be completely executed (for example, the source object is copied but not deleted), which may cause the source and target objects to coexist.
  • If the source bucket is a parallel file system (supporting POSIX), the destination bucket cannot be an object storage bucket.

Command Line Structure

  • Windows
    • Moving a single object
      obsutil mv obs://srcbucket/key obs://dstbucket/[dest] [-dryRun] [-u] [-p=1] [-threshold=52428800] [-versionId=xxx] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-cpd=xxx] [-fr] [-o=xxx] [-config=xxx] 
    • Moving objects in batches
      obsutil mv obs://srcbucket[/key] obs://dstbucket[/dest] -r [-dryRun] [-f] [-flat] [-u] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] 
  • macOS or Linux
    • Moving a single object
      ./obsutil mv obs://srcbucket/key obs://dstbucket/[dest] [-dryRun] [-u] [-p=1] [-threshold=52428800] [-versionId=xxx] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-cpd=xxx] [-fr] [-o=xxx] [-config=xxx] 
    • Moving objects in batches
      ./obsutil mv obs://srcbucket[/key] obs://dstbucket[/dest] -r [-dryRun] [-f] [-flat] [-u] [-j=1] [-p=1] [-threshold=52428800] [-acl=xxx] [-sc=xxx] [-meta=aaa:bbb#ccc:ddd] [-ps=auto] [-include=*.xxx] [-exclude=*.xxx] [-timeRange=time1-time2] [-mf] [-o=xxx] [-cpd=xxx] [-config=xxx] 
  • The source and destination paths cannot be the same.
  • The source and destination paths cannot be nested during batch moves.
  • Batch object moves are not supported for parallel file systems.

Examples

  • In Windows, run obsutil mv obs://bucket-test/key obs://bucket-test2 to move a single object.
    obsutil mv obs://bucket-test/key obs://bucket-test2
    Start at 2024-09-30 08:36:01.3934921 +0000 UTC
    
    Parallel:      5                   Jobs:          5
    Threshold:     50.00MB             PartSize:      auto
    CheckpointDir: xxxx
    
    [=====================================================] 100.00% 6/s 0s
    Waiting for the copied key to be completed on server side.
    
    Move successfully, 19B, obs://bucket-test/key --> obs://bucket-test2/key, cost [1815], status [200], request id [00000192421282AC401423183A8B83A1]
  • In Windows, run obsutil mv obs://bucket-test/temp/ obs://bucket-test2 -f -r to move objects in batches.
    obsutil mv obs://bucket-test/temp/ obs://bucket-test2 -f -r
    Start at 2024-09-30 08:37:32.2454905 +0000 UTC
    
    Parallel:      5                   Jobs:          5
    Threshold:     50.00MB             PartSize:      auto
    CheckpointDir: xxxx
    Task id: 0476929d-9d23-4dc5-b2f8-0a0493f027c5
    OutputDir: xxxx
    
    [=============================================================] 100.00% 10/s 0s
    Succeed count:   5         Failed count:    0
    Metrics [max cost:298 ms, min cost:192 ms, average cost:238.00 ms, average tps:9.71, transferred size: 7.20MB]
    Task id: 0476929d-9d23-4dc5-b2f8-0a0493f027c5

Parameter Description

Parameter

Optional or Mandatory

Description

srcbucket

Mandatory

The source bucket name

dstbucket

Mandatory

The destination bucket name

dest

Optional

The destination object name when moving a single object, or the name prefix of destination objects when moving objects in batches

key

Mandatory for moving a single object

Optional for moving objects in batches

The source object name when moving a single object, or the name prefix of source objects when moving objects in batches

The rules are as follows:

  • This parameter cannot be left blank when moving a single object. If dest is left blank, the source object is moved to the root directory of the destination bucket. If the value of dest ends with a slash (/), the destination object name is the value of dest plus the source object name. Otherwise, the destination object name is the value of dest.
  • If this parameter is left blank when moving objects in batches, all objects in the source bucket are moved. If not, objects whose name prefix is the set value in the source bucket are moved. The rules for confirming the name of the destination object are as follows:
    • If the value of dest ends with a slash (/), the destination object name is the value of dest plus the source object name.
    • If the value of dest does not end with a slash (/), the destination object name is the value of dest/source object name.
NOTE:
  • If this parameter is configured but parameter flat is not when moving objects in batches, the name of the source object contains the name prefix of the parent object. If flat is configured, then the name of the source object does not contain the name prefix of the parent object.
  • For details about how to use this parameter, see Command Line Structure.

fr

Optional for moving an object (additional parameter)

Generates an operation result file when moving an object.

flat

Optional for moving objects in batches (additional parameter)

The name prefix of the parent object is excluded when moving objects in batches.

dryRun

Optional (additional parameter)

Conducts a dry run.

u

Optional (additional parameter)

Indicates incremental move. If this parameter is set, each object can be moved only when it does not exist in the destination bucket, its size is different from the namesake one in the destination bucket, or it has the latest modification time.

NOTE:

If the size and modification time of the destination object are the same as those of the source object, the source object is directly deleted instead of being moved.

p

Optional (additional parameter)

The maximum number of concurrent multipart move tasks when moving an object. The default value is the value of defaultParallels in the configuration file.

threshold

Optional (additional parameter)

The threshold for enabling multipart move, in bytes. The default value is the value of defaultBigfileThreshold in the configuration file.

NOTE:
  • If the size of the object to be moved is smaller than the threshold, move the object directly. If not, a multipart move is required.
  • If you move an object directly, no part record is generated, and resumable transmission is not supported.
  • This parameter value can contain a unit, for example, 1MB (indicating 1,048,576 bytes).

versionId

Optional for moving an object (additional parameter)

The source object version ID that can be specified when moving a single object

NOTE:

Parameter versionId cannot be configured for buckets that support POSIX.

acl

Optional (additional parameter)

The access control policies for destination objects that can be specified when moving objects. The value can be:

  • private
  • public-read
  • public-read-write
  • bucket-owner-full-control
NOTE:

The preceding four values indicate private read and write, public read, public read and write, and bucket owner full control.

sc

Optional (additional parameter)

The storage classes of the destination objects that can be specified when moving objects. The value can be:

  • standard: Standard storage class. It features low access latency and high throughput, and is applicable to storing frequently accessed data (multiple accesses per month) or data that is smaller than 1 MB.
  • warm: Warm storage class. It is ideal for storing infrequently accessed (less than 12 times a year) data, but when needed, the access has to be fast.
  • cold: Cold storage class. It provides secure, durable, and inexpensive storage for rarely-accessed (once a year) data.

meta

Optional (additional parameter)

The metadata of destination objects that can be specified when moving objects. The format is key1:value1#key2:value2#key3:value3.

NOTE:

The format example above indicates that the destination objects contain three groups of custom metadata: key1:value1, key2:value2, and key3:value3.

ps

Optional (additional parameter)

The size of each part in a multipart move task, in bytes. The value ranges from 100KB to 5GB. The default value is the value of defaultPartSize in the configuration file.

NOTE:
  • This parameter value can contain a unit, for example, 1MB (indicating 1,048,576 bytes).
  • The parameter can be set to auto. In this case, obsutil automatically sets the part size for each multipart task based on the source object size.

cpd

Optional (additional parameter)

The folder where the part records reside. The default value is .obsutil_checkpoint, the subfolder in the home directory of the user who executes obsutil commands.

NOTE:

A part record is generated during a multipart move and saved to the copy subfolder. After the move succeeds, its part record is deleted automatically. If the move fails or is suspended, the system attempts to resume the task according to its part record when you perform the move the next time.

r

Mandatory for moving objects in batches (additional parameter)

Moves objects in batches based on a specified name prefix of objects in the source bucket.

f

Optional for moving objects in batches (additional parameter)

Runs in force mode.

j

Optional for moving objects in batches (additional parameter)

The maximum number of concurrent tasks for moving objects in batches. The default value is the value of defaultJobs in the configuration file.

NOTE:

The tool ensures that this value is at least 1.

exclude

Optional for moving objects in batches (additional parameter)

The matching patterns of source objects that are excluded, for example: *.txt

NOTE:
  • The asterisk (*) represents any group of characters, and the question mark (?) represents any single character. For instance, abc*.txt indicates any file whose name starts with abc and ends with .txt.
  • You can use \* to represent * and \? to represent ?.
  • If the name of the object to be moved matches the value of this parameter, the object is skipped.
NOTICE:
  • You are advised to use quotation marks for the matching pattern to prevent special characters from being escaped by the OS and leading to unexpected results. Use single quotation marks for Linux or macOS and double quotation marks for Windows.
  • The matching pattern applies to the object's absolute path, which includes the object name prefix and the object name starting from the root directory. For example, if an object's path in the bucket is obs://bucket/src1/src2/test.txt, its absolute path is src1/src2/test.txt.
  • This matching pattern applies only to objects whose names do not end with a slash (/).
  • Multiple exclude parameters can be specified, for example, -exclude=*.xxx -exclude=*.xxx.

include

Optional for moving objects in batches (additional parameter)

The matching patterns of source objects that are included, for example: *.jpg

NOTE:
  • The asterisk (*) represents any group of characters, and the question mark (?) represents any single character.
  • You can use \* to represent * and \? to represent ?.
  • The exclude rule is applied first. If the name of the object to be moved does not match the exclude rule, the system then checks whether the object name matches this parameter. If it does, the object is moved. If it does not, the object is skipped.
NOTICE:
  • You are advised to use quotation marks for the matching pattern to prevent special characters from being escaped by the OS and leading to unexpected results. Use single quotation marks for Linux or macOS and double quotation marks for Windows.
  • The matching pattern applies to the object's absolute path, which includes the object name prefix and the object name starting from the root directory. For example, if an object's path in the bucket is obs://bucket/src1/src2/test.txt, its absolute path is src1/src2/test.txt.
  • This matching pattern applies only to objects whose names do not end with a slash (/).
  • Multiple include parameters can be specified, for example, -include=*.xxx -include=*.xxx.

timeRange

Optional for moving objects in batches (additional parameter)

The time range matching pattern when moving objects. Only objects whose latest modification time is within the configured time range are moved.

This pattern has a lower priority than the object matching patterns (exclude/include). That is, the time range matching pattern is executed after the configured object matching patterns.

NOTE:
  • The matching time range is represented in time1-time2, where time1 must be earlier than or the same as time2. The time format is yyyyMMddHHmmss.
  • Automatic formatting is supported. For example, yyyyMMdd is equivalent to yyyyMMdd000000, and yyyyMM is equivalent to yyyyMM01000000.
  • If this parameter is set to *-time2, all files whose last modification time is earlier than time2 are matched. If it is set to time1-*, all files whose last modification time is later than time1 are matched.
NOTICE:
  • Time in the matching pattern is the UTC time.
  • This matching pattern applies only to objects whose names do not end with a slash (/).

mf

Optional (additional parameter)

Indicates that the name matching pattern (include or exclude) and the time matching pattern (timeRange) also take effect on objects whose names end with a slash (/).

o

Optional (additional parameter)

The folder that stores the result files. After the command is executed, result files (possibly success, failure, and warning files) will be created in the specified folder. The default value is .obsutil_output, a subfolder in the user's home directory where obsutil commands are executed.

NOTE:
  • A result file should be named as follows: mv_{succeed | failed | warning}_report_time_TaskId.txt.
  • By default, the maximum size of a single result file is 30 MB and the maximum number of result files that can be retained is 1,024. You can set the maximum size and number by configuring recordMaxLogSize and recordBackups in the configuration file.
  • If there are multiple folders and files and you need to confirm the details of a failed task, refer to the failure result file cp_failed_report_time_TaskId.txt in the result folder and the log files in the log path.

bucket-cname

Optional (additional parameter)

The user-defined domain name bound to the bucket

NOTE:

This parameter is only supported by obsutil 5.7.9 and later.

config

Optional (additional parameter)

The user-defined configuration file for executing the current command. For details about parameters that can be configured, see Configuration Parameters.

payer

Optional (additional parameter)

Specifies that requester pays is enabled.

Range:

requester

Response

Refer to Response for uploading an object.