HUAWEI Tool Guide User Manual

Object Storage Service
Tool Guide (obsutil)
Issue 16 Date 2021-03-22
HUAWEI TECHNOLOGIES CO., LTD.
Copyright © Huawei Technologies Co., Ltd. 2021. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any means without prior written consent of Huawei Technologies Co., Ltd.
Trademarks and Permissions
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd. All other trademarks and trade names mentioned in this document are the property of their respective holders.
Notice
The purchased products, services and features are stipulated by the contract made between Huawei and the customer. All or part of the products, services and features described in this document may not be within the purchase scope or the usage scope. Unless otherwise specied in the contract, all statements, information, and recommendations in this document are provided "AS IS" without warranties, guarantees or representations of any kind, either express or implied.
The information in this document is subject to change without notice. Every eort has been made in the preparation of this document to ensure accuracy of the contents, but all statements, information, and recommendations in this document do not constitute a warranty of any kind, express or implied.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. i
Object Storage Service Tool Guide (obsutil) Contents

Contents

1 Introduction to obsutil........................................................................................................... 1
2 Download and Installation....................................................................................................4
3 Getting Started........................................................................................................................ 6
3.1 Preparing the Environment..................................................................................................................................................6
3.2 Performing Initial
3.3 Quick Start.................................................................................................................................................................................9
Conguration........................................................................................................................................ 8
4 Bucket Commands................................................................................................................ 12
4.1 Creating a Bucket..................................................................................................................................................................12
4.2 Listing Buckets....................................................................................................................................................................... 14
4.3 Querying Bucket Properties...............................................................................................................................................16
4.4 Setting Bucket Properties...................................................................................................................................................18
4.5 Deleting a Bucket..................................................................................................................................................................21
4.6 Conguring a Bucket Policy.............................................................................................................................................. 22
4.7 Obtaining a Bucket Policy..................................................................................................................................................23
4.8 Deleting a Bucket Policy.....................................................................................................................................................24
5 Object Commands................................................................................................................. 26
5.1 Creating a Folder...................................................................................................................................................................26
5.2 Uploading an Object............................................................................................................................................................28
5.3 Querying Object Properties............................................................................................................................................... 40
5.4 Setting Object Properties................................................................................................................................................... 42
5.5 Listing Objects........................................................................................................................................................................46
5.6 Copying an Object................................................................................................................................................................ 49
5.7 Moving an Object................................................................................................................................................................. 59
5.8 Downloading an Object......................................................................................................................................................68
5.9 Generating the Download Link of an Object..............................................................................................................79
5.10 Deleting an Object............................................................................................................................................................. 83
5.11 Synchronously Uploading Incremental Objects....................................................................................................... 86
5.12 Synchronously Copying Incremental Objects............................................................................................................94
5.13 Synchronously Downloading Incremental Objects...............................................................................................104
5.14 Restoring Objects from OBS Archive.........................................................................................................................112
5.15 Resuming a Failed Upload Task.................................................................................................................................. 115
5.16 Resuming a Failed Copy Task...................................................................................................................................... 123
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. ii
Object Storage Service Tool Guide (obsutil) Contents
5.17 Resuming a Failed Download Task............................................................................................................................ 132
5.18 Listing Multipart Upload Tasks................................................................................................................................... 139
5.19 Deleting a Multipart Upload Task..............................................................................................................................141
5.20 Creating an Authorization Code for Directory Sharing.......................................................................................144
5.21 Listing Objects by Using an Authorization Code.................................................................................................. 146
5.22 Downloading Objects by Using an Authorization Code..................................................................................... 149
6 Auxiliary Commands.......................................................................................................... 159
6.1 Updating a
6.2 Deleting Part Records....................................................................................................................................................... 160
6.3 Viewing Command Help Information......................................................................................................................... 162
6.4 Querying the Version Number.......................................................................................................................................164
6.5 Archiving Log Files............................................................................................................................................................. 164
6.6 Checking and Updating the Version............................................................................................................................ 166
6.7 Listing Failure Result Files............................................................................................................................................... 167
Conguration File....................................................................................................................................... 159
7 Common Examples............................................................................................................. 169
7.1 Upload.................................................................................................................................................................................... 169
7.2 Synchronous Upload..........................................................................................................................................................171
7.3 Download.............................................................................................................................................................................. 172
7.4 Synchronous Download....................................................................................................................................................174
7.5 Copy........................................................................................................................................................................................ 174
7.6 Synchronous Copy.............................................................................................................................................................. 175
7.7 Listing..................................................................................................................................................................................... 176
7.8 Listing Multipart Upload Tasks......................................................................................................................................177
7.9 Deleting All Multipart Upload Tasks in a Bucket.................................................................................................... 177
8 Fault Locating...................................................................................................................... 178
8.1 Overview................................................................................................................................................................................178
8.2 Log Files.................................................................................................................................................................................178
8.3 Result Lists............................................................................................................................................................................ 179
8.4 Return Codes........................................................................................................................................................................180
9 Best Practices....................................................................................................................... 182
9.1 Using the obsutil help Command to Search for Functions..................................................................................182
Conguring Scheduled Tasks Using the Crontab Command...............................................................................183
9.2
9.3 Setting obsutil Commands as Built-in Commands................................................................................................. 184
9.4 Conguring Auto Obtaining of Access Keys for obsutil........................................................................................187
9.5 Fine-Tuning obsutil Performance..................................................................................................................................188
9.6 Using obsutil for Resumable Data Transfer...............................................................................................................189
9.7 Using obsutil to Upload a Symbolic Link................................................................................................................... 190
Conguring an HTTP Proxy for obsutil.......................................................................................................................190
9.8
9.9 Using obsutil to Share Directories................................................................................................................................ 191
9.10 Using obsutil to Replicate Data Across Regions on the Client Side............................................................... 192
A Parameter Description.......................................................................................................193
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. iii
Object Storage Service Tool Guide (obsutil) Contents
B Change History.................................................................................................................... 204
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. iv
Object Storage Service Tool Guide (obsutil) 1 Introduction to obsutil

1 Introduction to obsutil

obsutil is a command line tool for accessing and managing OBS on HUAWEI CLOUD. You can use this tool to perform common creating buckets, uploading and downloading les/folders, and deleting les/ folders. If you are familiar with command line interface (CLI), obsutil is recommended for batch processing and automated tasks.
congurations on OBS, such as
obsutil is compatible with the Windows, Linux, and macOS operating systems (OSs). Table 1-1 lists the recommended OS versions. To obtain the obsutil download links and methods for
Table 1-1 Recommended OS versions for using obsutil
OS
Windows ● Windows 7
Linux ● SUSE 11
macOS macOS 10.13.4
Tool Advantages
dierent OSs, refer to Downloading obsutil.
Recommended Version
● Windows 8
● Windows 10
● Windows Server 2016
● EulerOS 2
● CentOS 7
obsutil features the following advantages:
1. Simple and easy to use
2. Lightweight and installation-free
3. Compatible with Windows, Linux, and macOS operating systems Diversied congurations and excellent performance
4.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 1
Object Storage Service Tool Guide (obsutil) 1 Introduction to obsutil
Application Scenarios
Automated backup and archiving, for example, periodically uploading local data to OBS.
Scenarios that cannot be implemented using other tools such as OBS Browser +, for example, synchronously uploading, downloading, and copying objects.
Functions
Table 1-2 lists obsutil functions.
Table 1-2 obsutil functions
Function Description
Basic operations on buckets
Basic operations on objects
Logging Allows you to congure logging on the client side to
Create buckets of dierent storage classes in specic regions, delete buckets, and obtain the bucket list and conguration information.
Manage objects, including uploading, downloading, deleting, and listing objects. Supported operations are detailed as follows:
● Upload one or more les or folders.
● Upload large les in multiple parts.
● Synchronously upload, download, and copy incremental objects.
● Copy a single object or copy multiple objects in batches by object name
● Move a single object or move objects in batches by object name
● Resume failed upload, download, or copy tasks.
record operations on buckets and objects for statistics analysis later.
prex.
prex.
Advanced bucket and object management operations are being developed continuously, and will be available in later versions of obsutil. You can also go to OBS Console and explore more. For details, see OBS Console Operation Guide.
Command Line Structure
The obsutil command line structures are as follows:
In Windows
obsutil
In Linux or macOS
./obsutil
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 2
command [parameters...] [options...]
command [parameters...] [options...]
NO TE
Object Storage Service Tool Guide (obsutil) 1 Introduction to obsutil
command indicates the command to be executed, for example, ls or cp.
parameters indicates the basic parameters (mandatory) of the command, for example, bucket name when creating a bucket.
options indicates the additional parameters (optional) of the command. Additional parameters must be preceded with a hyphen (-) when you run the command.
● The square brackets ([]) are not part of the command. Do not enclose parameter values with them when entering a command.
● If the command contains special characters including ampersands (&), angle brackets (<) and (>), and spaces, they need to be escaped using quotation marks. Use single quotation marks for Linux or macOS and quotation marks for Windows.
● Additional parameters can be input in the -
-acl=private, or -acl private. There is no dierence between the two formats. Select either one as you like.
● In Windows, you can directly execute obsutil.exe to enter an interactive command mode. In this mode, you can input
command [parameters...] [options...]
to run a command. An example is provided as follows:
Enter "exit" or "quit" to logout Enter "help" or "help command" to show help docs Input your command:
-->ls -limit=3 -s obs://bucket-001 obs://bucket-002 obs://bucket-003 Bucket number is: 3
key=value
or -
key value
format, for example,
without obsutil
Input your command:
-->
● If you use SSH to remotely log in to the Linux or macOS for running obsutil commands, you are advised to set TMOUT=0 to prevent the program from exiting due to the expiration of the SSH session.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 3
NO TE
Object Storage Service Tool Guide (obsutil) 2 Download and Installation

2 Download and Installation

Download Links
Table 2-1 lists the download links of obsutil for
Table 2-1 Download links of obsutil
Operatin g System
Windows (64-bit)
Linux AMD (64-bit)
Linux ARM (64-bit)
macOS (64-bit)
Download Link How to Use View Help
obsutil_windows64
obsutil_windows64_sha256
obsutil_linux_amd64
obsutil_linux_amd64_sha256
obsutil_linux_arm64
obsutil_linux_arm64_sha256
obsutil_mac64
obsutil_mac64_sha256
dierent operating systems.
After the download is complete, click
here to see how to
quickly get started with obsutil.
Basic functions
Listing Buckets
Uploading an
Object
Listing Objects
You can also click here to learn how to use the
help
command to get familiar with more functions of obsutil.
For details about the version revision records of obsutil, see ChangeLog.
Quick Installation
Methods of downloading obsutil vary according to dierent operating systems. obsutil is an installation-free tool and can be used after the package is downloaded and decompressed.
In Windows a. Directly download the obsutil package to your local PC using the
corresponding download link.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 4
NO TE
NO TE
NO TE
Object Storage Service Tool Guide (obsutil) 2 Download and Installation
b. After the download completes, decompress the package to a specied
folder.
c. Double-click obsutil.exe in the decompressed folder and then you can
use the tool.
Alternatively, you can open the CLI to go to the upper-level directory of obsutil.exe and run obsutil commands. The command line structures of the two modes are dierent. For details, see Command Line Structure.
In Linux a. Open the CLI and run the wget command to download the obsutil tool
package.
wget https://obs-community-intl.obs.ap-southeast-1.myhuaweicloud.com/obsutil/current/ obsutil_linux_amd64.tar.gz
You can also download the obsutil package from a PC running the Windows operating system and then use a cross-platform transfer tool (such as WinSCP) to transfer the package to your host running the Linux operating system.
b. Run the following command in the directory where the tool package
resides:
tar -xzvf obsutil_linux_amd64.tar.gz
c. Go to the directory where obsutil resides and run the following command
to grant the execute permission to obsutil:
chmod 755 obsutil
macOS a. Directly download the obsutil package to your local PC using the
corresponding download link.
b. After the download completes, decompress the package to a
specied
folder.
c. Open the CLI, go to the directory where obsutil resides, and run the
following command to grant the execute permission to obsutil:
chmod 755 obsutil
If you need to use obsutil on a HUAWEI CLOUD ECS, see the reference section below to congure access to OBS over intranet to save trac costs.
Accessing OBS over Intranet by Using obsutil on a Linux ECS
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 5
Object Storage Service Tool Guide (obsutil) 3 Getting Started

3 Getting Started

3.1 Preparing the Environment

To use obsutil, you need to register a cloud service account, enable OBS, and obtain the access keys (AK and SK)
rst.
Step 1 Register a cloud service account.
Before using OBS, ensure that you have a cloud service account.
1. Open a browser.
2. Log in to the HUAWEI CLOUD website at huaweicloud.com/intl/en-us/.
3. In the upper right corner of the page, click Register.
4. Enter the registration information and click Register.
Step 2 Enable OBS.
Ensure that your account balance is
1. Log in to OBS Console.
2. Click Fees in the upper right corner of the page. The Billing Center page is displayed.
3. Then click Top Up.
4. Top up the account as prompted.
5. Go back to the management console page after the recharging is successful.
6. Click Service List on the top menu bar. Choose Storage > Object Storage
Service to log in to OBS Console.
Step 3 (Optional) Create an IAM user.
sucient before using OBS.
For data security, it is recommended that you do not use the account directly to access OBS. Through the Identity and Access Management (IAM) service, you can create a user who has the permission to access OBS resources and manage buckets and objects on obsutil. If you do not need to use any IAM user, skip this step.
1. On the top navigation bar of the console, choose Service List > Management & Deployment > Identity and Access Management.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 6
NO TE
NO TE
NO TE
NO TE
NO TE
Object Storage Service Tool Guide (obsutil) 3 Getting Started
2. On the displayed IAM console page, create a user group with OBS permissions
congured.
For details, see Creating a User Group. After the user group is created, locate the row that displays Global service > OBS in the User Group Permissions, and click Congure Policy in the row to set OBS permissions for the user group.
For details about OBS policies, see Permissions Management
3. Create a user. For details, see Creating a User. When creating a user, set the User Group to
the one created in Step 3.2 with OBS permissions congured.
If the user group is not congured with OBS permissions, you can congure ne-grain permissions on OBS Console through bucket policies or object policies. For details, see
Permission Control.
Step 4 Obtain access keys.
OBS uses AKs and SKs in user accounts for signature verication to ensure that only authorized accounts can access
specied OBS resources. Detailed
explanations about AK and SK are as follows:
Access key ID (AK): indicates the ID of the access key, which is a unique identier used together with a secret access key to sign requests cryptographically.
Secret access key (SK): indicates the private key used together with its associated AK to cryptographically sign requests. The AK and SK are used together to identify a request sender to prevent the request from being
modied.
A user can create a maximum of two valid access keys.
Create access keys as follows:
1. In the upper right corner of the console page, select My Credential under the username.
2. On the My Credentials page, select Access Keys in the navigation pane on the left.
3. On the Access Keys page, click Add Access Key.
A user can create a maximum of two valid access keys.
4. In the Add Access Key dialog box that is displayed, enter the password and
verication code.
its
– If you have not bound an email address or mobile number, enter only the
password.
– If you have bound an email address and a mobile number, you can select the
verication by email or mobile phone.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 7
NO TE
NO TE
Object Storage Service Tool Guide (obsutil) 3 Getting Started
5. Click OK.
6. In the Download Access Key dialog box that is displayed, click OK to save the access keys to your browser's default download path.
Keep the access keys properly to prevent information leakage. If you click Cancel in the dialog box, the access keys will not be downloaded, and you cannot download them later. Re-create access keys if required.
7. Open the downloaded credentials.csv le to obtain the access keys (AK and SK).
In the access key le, the value in the Access Key ID column is the AK, and the value in the Secret Access Key column is the SK.
----End
3.2 Performing Initial Conguration
Before using obsutil, you need to congure the interconnection between obsutil and OBS, including the endpoint and access keys (AK and SK) of OBS. You can use obsutil to perform operations on OBS buckets and objects only after obtaining the OBS authentication.
Prerequisites
You have downloaded the software package of obsutil. For details, see
Download and Installation.
You have obtained the enabled regions and endpoints of OBS. For details, see
Regions and Endpoints. If you want to access OBS in the AP-Hong Kong
region, the actual OBS service address is: https://obs.ap­southeast-3.myhuaweicloud.com.
You have obtained the access keys (AK and SK). For details about how to obtain access keys, see Preparing the Environment. Click here to open the access key management page.
Conguration Method
Method 1: Run the cong command, see Updating a Conguration File. The following is an example:
cong command to initialize obsutil. For details about the
In Windows
obsutil cong -i=ak -k=sk -e=
endpoint
In Linux or macOS
./obsutil cong -i=ak -k=sk -e=
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 8
endpoint
NO TE
NO TE
Object Storage Service Tool Guide (obsutil) 3 Getting Started
● After running the preceding commands, a conguration le .obsutilcong is automatically generated in the same home directory of the user who executes obsutil commands (the ~ directory in Linux or macOS, and the C:\Users\ in Windows).
● For details about the parameters in the .obsutilcong le, see Parameter Description.
● The .obsutilcong le contains the AK and SK information of a user. Therefore, it is hidden by default to prevent key disclosure. To query the le, run the following command in the home directory of the user who executes obsutil commands.
In Windows
dir
In Linux or macOS
ls -a
or
ls -al
● obsutil encrypts the AK and SK in the
● Note: You can use the -i, -k, and -e options to authentication. You can run the history command in the Linux OS to query the parameter values. Exercise caution when performing this operation.
.obsutilcong contains all the conguration information of obsutil.
.obsutilcong le to ensure key security.
congure user information for
<Username>
directory
Method 2: You can use Conguring Auto Obtaining of Access Keys for obsutil to implement initial
Checking the Connectivity
After the the following commands:
In Windows
In Linux or macOS
Check the conguration result based on the command output:
If the command output contains Bucket number is:, the conguration is
If the command output contains Http status [403], the access keys are
If the command output contains A connection attempt failed, then OBS
conguration is complete, you can check whether it is correct by running
obsutil ls -s
./obsutil ls -s
correct.
incorrectly congured.
cannot be accessed. In this case, check the network condition.
conguration.
If the command output contains Http status [403], you may not have the required permissions for obtaining the bucket list. In this case, further locate the root cause based on the specic situation.

3.3 Quick Start

This section uses the Linux OS as an example to describe how to use obsutil to perform basic data operations in OBS. For details, see Figure 3-1.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 9
NO TE
Object Storage Service Tool Guide (obsutil) 3 Getting Started
Figure 3-1 obsutil ow for a quick start
Prerequisites
Procedure
Step 1 Run the ./obsutil mb obs://bucket-test -location=cn-south-1 command to create
Step 2 Run the ./obsutil cp /temp/test.txt obs://bucket-test/test.txt command to
You have obtained obsutil and completed initial conguration.
The directory saving the tool is accessed.
a new bucket named bucket-test in the CN South-Guangzhou region.
./obsutil mb obs://bucket-test -location=cn-south-1
Create bucket [bucket-test] successfully!
In the preceding command, parameter location indicates the region where a bucket is created. It is mandatory only when the endpoint set during initial conguration belongs to any other regions than the default one CN North-Beijing1 (cn-north-1). Click here to query currently valid regions.
upload the test.txt le to bucket bucket-test.
./obsutil cp /temp/test.txt obs://bucket-test/test.txt
Parallel: 5 Jobs: 5 Threshold: 52428800 PartSize: 5242880 Exclude: Include:
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 10
Object Storage Service Tool Guide (obsutil) 3 Getting Started
VerifyLength: false VerifyMd5: false CheckpointDir: /temp/.obsutil_checkpoint
test.txt:[==============================================] 100.00% 48.47 KB/s 0s Upload successfully, 4.44KB, /temp/test.txt --> obs://bucket-test1/test.txt
Step 3 Run the ./obsutil cp obs://bucket-test/test.txt /temp/test1.txt command to
download test.txt from bucket bucket-test to a local PC.
./obsutil cp obs://bucket-test/test.txt /temp/test1.txt
Parallel: 5 Jobs: 5 Threshold: 52428800 PartSize: 5242880 Exclude: Include: VerifyLength: false VerifyMd5: false CheckpointDir: /temp/.obsutil_checkpoint
test.txt:[=============================================] 100.00% 775.52 KB/s 0s Download successfully, 4.44KB, obs://bucket-test1/test.txt --> /temp/test1.txt
Step 4 Run the ./obsutil rm obs://bucket-test/test.txt -f command to delete object
test.txt from bucket bucket-test.
./obsutil rm obs://bucket-test/test.txt -f
Delete object [test.txt] in the bucket [bucket-test] successfully!
Step 5 Run the ./obsutil rm obs://bucket-test -f command to delete bucket bucket-test.
./obsutil rm obs://bucket-test -f
Delete bucket [bucket-test] successfully!
----End
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 11
NO TE
NO TICE
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands

4 Bucket Commands

4.1 Creating a Bucket

Function
You can use this command to create a bucket. A bucket name must be unique in OBS. One account can create a maximum of 100 buckets.
If you create a bucket and name it the same as an existing one in the same account and region, no error will be reported and status code 200 is returned. The bucket properties comply with those set in the rst creation request. In other cases, creating a bucket with the same name as an existing one will receive the status code 409, indicating that the bucket already exists.
If the congured endpoint is a global domain name, you may need to wait several minutes before uploading objects to the created bucket. Therefore, set the endpoint to a regional domain name according to Performing Initial
Conguration if you want to upload objects instantly to the bucket.
Command Line Structure
In Windows
obsutil mb obs://bucket [-acl=xxx] [-sc=xxx] [-location=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [­t=xxx]
In Linux or macOS
./obsutil mb obs://bucket [-acl=xxx] [-sc=xxx] [-location=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil mb obs://bucket-test command to create a bucket. The creation is successful.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 12
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
obsutil mb obs://bucket-test
Create bucket [bucket-test] successfully, request id [0000016979E1D2EA860BB5E80A6B8FCC]
Take the Windows OS as an example. Run the obsutil mb obs://bucket001 command to create a namesake bucket. The creation fails.
obsutil mb obs://bucket001
Create bucket [bucket001] failed, http status [409], error code [BucketAlreadyExists], error message [The requested bucket name is not available. The bucket namespace is shared by all users of the system. Please select a [04030000016757F31A0333281A6B1E92]
dierent name andtry again.], request id
Parameter Description
Parame ter
Optional or Mandatory
Description
bucket Mandatory Bucket name
NOTE
A bucket name must comply with the following rules:
● Contains 3 to 63 characters, including lowercase letters, digits, hyphens (-), and periods (.), and starts with a digit or letter.
● Cannot be an IP address.
● Cannot start or end with a hyphen (-) or period (.).
● Cannot contain two consecutive periods (.), for example, my..bucket.
● Cannot contain periods (.) and hyphens (-) adjacent to each other, for example, my-.bucket or my.- bucket.
acl Optional
(additional parameter)
Access control policies that can be specied when creating a bucket. Possible values are:
● private
● public-read
● public-read-write
NOTE
The preceding three values indicate private read and write, public read, and public read and write.
sc Optional
(additional parameter)
Default bucket storage class that can be specied when creating a bucket. Possible values are:
standard: OBS Standard, which 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: OBS Infrequent Access. It is applicable to storing infrequently accessed (less than 12 times a year) data that requires quick response.
cold: OBS Archive. It is secure, durable, and inexpensive, and applicable to archiving rarely­accessed (once a year) data.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 13
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parame ter
Optional or Mandatory
location Mandatory
unless the region where the OBS service resides is not the default region (additional parameter)
cong Optional
(additional parameter)
e Optional
(additional parameter)
i Optional
(additional parameter)
Description
Region where the bucket resides.
NOTE
This parameter indicates the region where a bucket will be created. It is mandatory only when the endpoint belongs to any other regions than the default one CN North-Beijing1 (cn-north-1). Click here to query currently valid regions.
User-dened conguration le for executing a command. For details about parameters that can be congured, see Parameter Description.
Species the endpoint.
Species the user's AK.
k Optional
(additional parameter)
t Optional
(additional parameter)

4.2 Listing Buckets

Function
You can use this command to obtain the bucket list. In the list, bucket names are displayed in lexicographical order.
Command Line Structure
In Windows
obsutil ls [-s] [-sc] [-j=1] [-limit=1] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil ls [-s] [-sc] [-j=1] [-limit=1] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Species the user's SK.
Species the user's security token.
Examples
Take the Windows OS as an example. Run the obsutil ls -limit=5 command to obtain the bucket list.
obsutil ls -limit=5
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 14
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Bucket CreationDate Location BucketType obs://bucket001 2018-09-03T01:53:02Z example OBJECT
obs://bucket002 2018-11-01T01:40:01Z example OBJECT
obs://bucket003 2018-10-25T11:45:45Z example OBJECT
obs://bucket004 2018-10-26T02:33:09Z example OBJECT
obs://bucket005 2018-10-26T02:34:50Z example OBJECT
Bucket number is: 5
Parameter Description
Parameter Optional or Mandatory Description
s Optional (additional
parameter)
sc Optional (additional
parameter)
j Optional (additional
parameter). It must be used together with sc.
limit Optional (additional
parameter)
cong Optional (additional
parameter)
Displays simplied query result.
NOTE
In the simplied format, the returned result contains only the bucket name.
Queries the storage classes of the buckets when listing buckets.
Indicates the maximum number of concurrent tasks for querying the bucket storage class. The default value is the value of defaultJobs in the conguration le.
NOTE
The value is ensured to be greater than or equal to 1.
Maximum number of buckets that can be queried. If the value is less than 0, all buckets are listed. If it is left blank, a maximum of 1000 buckets can be listed by default.
User-dened conguration le for executing a command. For details about parameters that can be congured, see Parameter
Description.
e Optional (additional
Species the endpoint.
parameter)
i Optional (additional
Species the user's AK.
parameter)
k Optional (additional
Species the user's SK.
parameter)
t Optional (additional
Species the user's security token.
parameter)
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 15
NO TE
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
In the bucket listing result, the BucketType eld indicates the bucket type; OBJECT indicates the bucket for object storage.

4.3 Querying Bucket Properties

Function
You can use this command to query the basic properties of a bucket, including its default storage class, region, version ID, storage usage, bucket quota, and the number of objects in the bucket.
Command Line Structure
In Windows
obsutil stat obs://bucket [-acl] [-bf=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil stat obs://bucket [-acl] [-bf=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil stat obs://bucket-test command to query the basic properties of bucket bucket-test.
obsutil stat obs://bucket-test
Bucket: obs://bucket-test StorageClass: standard
ObsVersion:
3.0 ObjectNumber: 8005 Size: 320076506 Quota: 0
Parameter Description
Parameter
bucket Mandatory Bucket name acl Optional Queries the access control policies of the
Optional or Mandatory
Description
bucket while querying bucket properties.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 16
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Optional or
Mandatory
bf Optional
(additional parameter)
cong Optional
(additional parameter)
e Optional
(additional parameter)
i Optional
(additional parameter)
Description
Display format of the used bucket capacity (in bytes) Value options:
● human-readable
● raw
NOTE
If this parameter is not congured, the display format of the used bucket capacity (in bytes) is determined by the humanReadableFormat parameter in the
conguration le.
User-dened conguration le for executing
a command. For details about parameters that can be congured, see Parameter
Description.
Species the endpoint.
Species the user's AK.
Response
k Optional
Species the user's SK. (additional parameter)
t Optional
Species the user's security token. (additional parameter)
payer Optional
(additional
Species that requester-pays is enabled on a
bucket. parameter)
Field
Description
Bucket Bucket name StorageClass Default storage class of the bucket Location Region where the bucket resides ObsVersion Version of the bucket BucketType Type of a bucket. OBJECT indicates a bucket for object
storage.
ObjectNumber Number of objects in the bucket
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 17
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Field Description
Size Storage usage of the bucket, in bytes Quota Bucket quota. Value 0 indicates that no upper limit is set for
the bucket quota.
Acl Access control policy of the bucket

4.4 Setting Bucket Properties

Function
You can use this command to set the properties of a bucket, such as storage classes and access policies.
Command Line Structure
In Windows
obsutil chattri obs://bucket [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil chattri obs://bucket [-sc=xxx] [-acl=xxx] [-aclXml=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [­k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil chattri obs://bucket­test -acl=private command to change the access control policy of the bucket
to private read and write.
obsutil chattri obs://bucket-test -acl=private
Set the acl of bucket [bucket-test] to [private] successfully, request id [04050000016836C5DA6FB21F14A2A0C0]
Parameter Description
Parameter
bucket Mandatory Bucket name
Optional or Mandatory
Description
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 18
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Optional or
Mandatory
sc Optional
(additional parameter)
acl Optional
(additional parameter)
Description
Default storage class of the bucket. Possible values are:
standard: OBS Standard, which 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: OBS Infrequent Access. It is applicable to storing infrequently accessed (less than 12 times a year) data that requires quick response.
cold: OBS Archive. It is secure, durable, and inexpensive, and applicable to archiving rarely-accessed (once a year) data.
Access control policies that can be specied for buckets. Possible values are:
● private
● public-read
● public-read-write
NOTE
The preceding three values indicate private read and write, public read, and public read and write.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 19
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Optional or
Mandatory
aclXml Optional
(additional parameter)
Description
Access control policy of the bucket, in XML format.
<AccessControlPolicy> <Owner> <ID> </Owner> <AccessControlList> <Grant> <Grantee> <ID> </Grantee> <Permission>
READ_ACP|FULL_CONTROL]
</Grant> <Grant> <Grantee> <Canned>Everyone</Canned> </Grantee> <Permission>
READ_ACP|FULL_CONTROL]
</Grant> </AccessControlList> </AccessControlPolicy>
NOTE
NOTICE
ownerid
</ID>
userid
</ID>
[WRITE|WRITE_ACP|READ|
</Permission>
[WRITE|WRITE_ACP|READ|
</Permission>
Owner: Optional. Specify the bucket owner's ID.
● In AccessControlList, the Grant the authorized users. Grantee IDs of authorized users. Canned species the authorized user group (currently, only Everyone is supported).
● The following permissions can be granted: WRITE (write), WRITE_ACP (write ACL), READ (read), READ_ACP (read ACL), and FULL_CONTROL (full control).
Because angle brackets (<) and (>) are unavoidably included in the parameter value, you must use quotation marks to enclose them for escaping when running the command. Use single quotation marks for Linux or macOS and quotation marks for Windows.
eld contains
species the
cong
Optional (additional parameter)
User-dened conguration le for executing a command. For details about parameters that can be congured, see Parameter
Description.
e Optional
Species the endpoint. (additional parameter)
i Optional
Species the user's AK. (additional parameter)
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 20
NO TE
NO TE
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Optional or
Mandatory
k Optional
(additional parameter)
t Optional
(additional parameter)
payer Optional
(additional parameter)
Only one from sc, acl, or aclXml can be set for each command.

4.5 Deleting a Bucket

Description
Species the user's SK.
Species the user's security token.
Species that requester-pays is enabled on a
bucket.
Function
You can use this command to delete a bucket. The bucket to be deleted must be empty (containing no objects, historical versions, or fragments).
To delete a non-empty bucket, run the commands in Deleting a Multipart Upload Task and Deleting an Object to clear the bucket, and then run the following command to delete the bucket.
Command Line Structure
In Windows
obsutil rm obs://bucket [-f] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil rm obs://bucket [-f] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil rm obs://bucket-test command to delete bucket bucket-test.
obsutil rm obs://bucket-test
Do you want delete bucket [bucket-test] ? Please input (y/n) to conrm: y Delete bucket [bucket-test] successfully!
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 21
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Description
Parameter Optional or
Mandatory
bucket Mandatory Bucket name f Optional (additional
parameter)
cong Optional (additional
parameter)
e Optional (additional
parameter)
i Optional (additional
parameter)
k Optional (additional
parameter)
t Optional (additional
parameter)
payer Optional (additional
parameter)
Description
Runs in force mode.
User-dened conguration le for executing a command. For details about parameters that can be congured, see
Parameter Description.
Species the endpoint.
Species the user's AK.
Species the user's SK.
Species the user's security token.
Species that requester-pays is enabled on
a bucket.
4.6 Conguring a Bucket Policy
Function
You can use this command to congure a bucket policy.
Command Line Structure
In Windows
obsutil bucketpolicy obs://bucket -method=put -localle=xxx [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil bucketpolicy obs://bucket -method=put -localle=xxx [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil bucketpolicy obs:// bucket -method=put bucket policy based on le policy.json.
obsutil bucketpolicy obs://bucket -method=put -localle=d:\temp\policy.json
-localle=d:\temp\policy.json command to set a
Put bucketPolicy succeed, requestId is [04050000016836C5DA6FB21F14A2A0C0]
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 22
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Parameter Description
Parameter Optional or
Mandatory
bucket Mandatory Bucket name method Mandatory Species the method. Set this parameter to put
localle Mandatory Path of the local policy le to import cong Optional
(additional parameter)
e Optional
(additional parameter)
i Optional
(additional parameter)
k Optional
(additional parameter)
Description
when conguring a bucket policy.
User-dened conguration le for executing a
command. For details about parameters that can be congured, see Parameter Description.
Species the endpoint.
Species the user's AK.
Species the user's SK.
t Optional
(additional parameter)
payer Optional
(additional parameter)
Species the user's security token.
Species that requester-pays is enabled on a
bucket.

4.7 Obtaining a Bucket Policy

Function
You can use this command to obtain a bucket policy.
Command Line Structure
In Windows
obsutil bucketpolicy obs://bucket -method=get [-localle=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil bucketpolicy obs://bucket -method=get [-localle=xxx] [-cong=xxx] [-e=xxx] [-i=xxx] [­k=xxx] [-t=xxx]
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 23
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Examples
Take the Windows OS as an example. Run the obsutil bucketpolicy obs:// bucket -method=get -localle=d:\temp\policy.json command to export the bucket policy to local le policy.json.
obsutil bucketpolicy obs://bucket -method=get -localle=d:\temp\policy.json
Export bucketPolicy to [d:\temp\policy.json] succeed, requestId is [04050000016836C5DA6FB21F14A2A0C0]
Parameter Description
Parameter Optional or
Mandatory
bucket Mandatory Bucket name method Mandatory Species the method. Set this parameter to gut
localle Optional
(additional parameter)
cong Optional
(additional parameter)
e Optional
(additional parameter)
i Optional
(additional parameter)
k Optional
(additional parameter)
Description
when obtaining a bucket policy. If this parameter is set, the policy is exported to a
local le. If not set, the policy is exported in a standard manner by default.
User-dened conguration le for executing a command. For details about parameters that can be congured, see Parameter Description.
Species the endpoint.
Species the user's AK.
Species the user's SK.
t Optional
(additional parameter)
payer Optional
(additional parameter)
Species the user's security token.
Species that requester-pays is enabled on a
bucket.

4.8 Deleting a Bucket Policy

Function
You can use this command to delete a bucket policy.
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 24
Object Storage Service Tool Guide (obsutil) 4 Bucket Commands
Command Line Structure
In Windows
obsutil bucketpolicy obs://bucket -method=delete [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
In Linux or macOS
./obsutil bucketpolicy obs://bucket -method=delete [-cong=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
Take the Windows OS as an example. Run the obsutil bucketpolicy obs:// bucket -method=delete command to delete a bucket policy.
obsutil bucketpolicy obs://bucket -method=delete
Delete bucketPolicy succeed, requestId is [04050000016836C5DA6FB21F14A2A0C0]
Parameter Description
Parameter Optional or
Description
Mandatory
bucket Mandatory Bucket name method Mandatory Species the method. Set this parameter to delete
when deleting a bucket policy.
cong Optional
(additional parameter)
e Optional
User-dened conguration le for executing a command. For details about parameters that can be congured, see Parameter Description.
Species the endpoint. (additional parameter)
i Optional
Species the user's AK. (additional parameter)
k Optional
Species the user's SK. (additional parameter)
t Optional
Species the user's security token. (additional parameter)
payer Optional
(additional
Species that requester-pays is enabled on a
bucket. parameter)
Issue 16 (2021-03-22) Copyright © Huawei Technologies Co., Ltd. 25
Loading...
+ 182 hidden pages