March 11, 2021

Various OCI CLI command for OCI Object Storage administration



·       Command to create bucket

Syntax:

oci os bucket create --compartment-id <compartment id> --name <bucket name>

 

Example:

oci os bucket create --compartment-id ocid1.compartment.oc1..aaaaaaaacgen54z6eyimw7pnp4a553425kifsq --name TESTBUCKET

 

 

 

·       Command to delete bucket

Syntax :

oci os bucket delete --name <Bucket name>

 

Example :

oci os bucket delete --name TESTBUCKET

 

 

·       Command to list out all the objects inside a bucket

Syntax:

oci os object list --bucket-name < Bucket name >             

 

Example:

oci os object list --bucket-name TESTBUCKET     

 

·       Command to upload files inside a bucket.

Syntax:

oci os object put –bn <Bucket_Name> --name <uploaded file_name > --file<source file_name>

 

Example:

oci os object put -bn TESTBUCKET --name x.sql --file x.sql

 

·       Command to upload files inside a directory created under a bucket.

Syntax:

oci os object put –bn <Bucket Name> --name <Direcotry name/uploaded file name> --file <source file name>

 

Example:

oci os object put -bn TESTBUCKET --name Backup/x.sql --file x.sql

 

·       Command to Download a file residing inside a bucket.

Syntax:

oci os object bulk-download –bn <Bucket Name> --download-dir <Path where file would be downloaded> --prefix <File which would be downloaded>

 

 

Example:

oci os object bulk-download -bn TESTBUCKET --download-dir /home/oracle --prefix x.sql

 

·       Command to Download files from a directory which is created under a bucket.

Syntax:

oci os object bulk-download –ns <Bucket namespace> -bn <Bucket Name> --download-dir

<Path where file would be downloaded> --prefix <Directory path/file name which would be downloaded>

 

Example:

oci os object bulk-download -ns bm1uufa0a -bn TESTBUCKET --download-dir /home/oracle --prefix Backup/x.sql

  

 Command to Download all files from a bucket

Syntax:

oci os object bulk-download –ns <Bucket namespace> -bn <Bucket Name> --download-dir <Path where file would be downloaded>

 

oci os object bulk-download -ns bm642gedufa0a -bn TESTBUCKET --download-dir /home/oracle

·     

  Command to delete file from bucket

Syntax:

oci os object delete -bn <Bucket Name> --object-name <Name of object to delete>

 

Example:

oci os object delete -bn TESTBUCKET --object-name t1.sql

 

·       Command to delete file from a folder residing inside bucket

Syntax:

oci os object delete -bn <Bucket Name> --object-name <Location from where file to be delete>

 

Example:

oci os object delete -bn TESTBUCKET --object-name Backup/x.sql

 

Command to find out all of the in-progress multipart uploads

Syntax:-

oci os multipart list --namespace-name <Bucket_Namespace> –bn <Bucket_Name>


 Example:

oci os multipart list --namespace-name lsaf54dfae -bn TESTBUCKET

 

Command to abort or remove in-progress multipart uploads

Syntax:-

oci os multipart abort -bn <Bucket_name> --object-name <object_name> --upload-id <upload_ID>

 Example:-

oci os multipart abort -bn TESTBUCKET --object-name PROD_backup_12042021/rman_bkp_9.tar.gz --upload-id 941a510d-37ec-2ddb-8b63-112634475f52

 

 

 

7 comments:

  1. oci os object copy --bucket-name $bucket_name --destination-bucket $destination_bucket --source-object-name $source_object_name
    What option i should give if i want to copy all files in a directory (of bucket)

    ReplyDelete
    Replies
    1. oci os object put –bn --name --file

      Use this to copy/upload all files inside a directory of a bucket.

      Delete
  2. How to download folder/directory inside the bucket using cli command?

    ReplyDelete
  3. HI,
    Crisp article. Thanks
    if, i have folder called arch,fra under oradata folder.
    How to do bulkload all files excluding folder /oradata/arch and /oradata/arch.
    is it possible. ?

    ReplyDelete
    Replies
    1. i found answer. We should use
      --exclude '/u01/app/oracle/oradata/pdc/arch/*' --exclude '/u01/app/oracle/oradata/pdc/fra/*'

      Delete
  4. Does any one identified how to upload/sync file from source server over to Object storage preserving original file timestamps? All I see is the uploaded timestamp and as I download the file, the timestamp is becoming current but not able to retrieve original timestamp of the file.

    ReplyDelete
  5. Appreciate the content quality

    ReplyDelete

Datapatch Fails in Oracle 12c on Windows – Root Cause and Step-by-Step Fix

   Recently, while applying a patch on an Oracle 12c (12.2.0.1) database on Windows, I ran into a frustrating issue: datapatch kept failin...