The inventory command is used to add, query, list, or delete inventories for a bucket.
Note
- The commands described in this topic apply to Linux. To use the commands in other systems, replace ./ossutil in the command with the actual executable program name. For example, you can use the help command in 32-bit Windows systems by running ossutil32.exe help.
- For more information about bucket inventory, see Bucket inventory.
Command syntax
- Add an inventory
ossutil reads the inventory configurations in local_xml_file, and adds the inventory obtained from the configuration file for the bucket. If the inventory ID already exists, HTTP status code 409 is returned../ossutil inventory --method put oss://bucket local_xml_file [options]
The configuration file is in the XML format. The following code provides an example on the configurations of an inventory:<InventoryConfiguration> <Id>report1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>filterPrefix</Prefix> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>1000000000000000</AccountId> <RoleArn>acs:ram::1000000000000000:role/bucket-inventory-role</RoleArn> <Bucket>acs:oss:::destination-bucket</Bucket> <Prefix>prefix1</Prefix> <Encryption> <SSE-KMS> <KeyId>keyId</KeyId> </SSE-KMS> </Encryption> </OSSBucketDestination> </Destination> <Schedule> <Frequency>Daily</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> <Field>IsMultipartUploaded</Field> <Field>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>
Notice Before you configure inventories, you must create a RAM role to obtain the permissions to read all objects in the source bucket and write objects to the destination bucket. For more information about how to create a RAM role, see Create a RAM role for a trusted Alibaba Cloud service. - Query an inventory
Query the inventory that has a specified inventory ID. If you specify local_xml_file, the inventory configurations will be exported to this file. Otherwise, the inventory configurations will be displayed on the screen../ossutil inventory --method get oss://bucket ruleid [local_xml_file] [options]
- List inventories
List all inventories including the inventory configurations for a specified bucket. If you specify local_file, the inventory configurations will be exported to this file. Otherwise, the inventory configurations will be displayed on the screen../ossutil inventory --method list oss://bucket [local_file] [--marker marker] [options]
- Delete an inventory
./ossutil inventory --method delete oss://bucket ruleid
Examples
- Add an inventory
For example, create an inventory that retrieves the size, last update time, ETag, storage class, and encryption status of the objects whose names contain the prefix of test in bucket1. Store the retrieved data as an inventory list in the abc folder of bucket2. Configure no encryption for the inventory list. The inventory.xml file contains the following content:./ossutil inventory --method put oss://bucket1 /file/inventory.xml
<? xml version="1.0" encoding="UTF-8"? > <InventoryConfiguration> <Id>inventory_id</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>abc</Prefix> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>174649585760****</AccountId> <RoleArn>acs:ram::174649585760****:role/inventoryrole</RoleArn> <Bucket>acs:oss:::bucket2</Bucket> <Prefix>test</Prefix> </OSSBucketDestination> </Destination> <Schedule> <Frequency>Daily</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> <Field>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>
- Query the inventory whose name is inventory_id
./ossutil inventory --method get oss://bucket1 inventory_id <? xml version="1.0" encoding="UTF-8"? > <InventoryConfiguration> <Id>test1</Id> <IsEnabled>true</IsEnabled> <Filter> <Prefix>abc</Prefix> </Filter> <Destination> <OSSBucketDestination> <Format>CSV</Format> <AccountId>174649585760****</AccountId> <RoleArn>acs:ram::174649585760****:role/inventoryrole</RoleArn> <Bucket>acs:oss:::bucket2</Bucket> <Prefix>test</Prefix> </OSSBucketDestination> </Destination> <Schedule> <Frequency>Daily</Frequency> </Schedule> <IncludedObjectVersions>All</IncludedObjectVersions> <OptionalFields> <Field>Size</Field> <Field>LastModifiedDate</Field> <Field>ETag</Field> <Field>StorageClass</Field> <Field>EncryptionStatus</Field> </OptionalFields> </InventoryConfiguration>
- List inventories and store them in a local device
./ossutil inventory --method get oss://bucket1 /file/inventory2.xml
- Delete the inventory whose name is inventory_id
./ossutil inventory --method delete oss://bucket1 inventory_id
Common options
The following table describes the options you can add to the inventory command.
Option | Description |
---|---|
--method | Specifies the operation type of the command. Valid values:
|
--loglevel | Specifies the log level. The default value is null, which indicates that no log files
are generated. Valid values:
|
--proxy-host | Specifies the URL of the proxy server. HTTP, HTTPS, and SOCKS5 proxies are supported. Examples: http://120.79. **.**:3128 and socks5://120.79. **. **:1080. |
--proxy-user | Specifies the username of the proxy server. The default value is null. |
--proxy-pwd | Specifies the password of the proxy server. The default value is null. |
--marker | Specifies the bucket name, inventory ID, object name, or multipart upload ID from which you want to start listing. |
Note For more information about common options, see View all supported options.