Skip to content

Huawei Cloud OBS CLI ile Bucket Yönetimi

Huawei Cloud üzerinde OBS CLI aracı ile bazı komutlara göz atalım.

OBS Nedir?

OBS Huawei Cloud üzerinde depolama amacıyla kullanılan bir bucket servisidir. Bu servis içerisinde dilediğimiz dosyaları tutabiliriz.

Console üzerinden OBS ile ilgili işlemleri yapabiliriz fakat bu içerikte obsutil cli aracı ile testlerimizi yapıyor olacağız. Test içeriğinde ise, temel işlemlere göz atıyor olacağız.

Console üzerinden obsutil cli aracına erişebiliriz ya da, buradaki linkten obs ile ilgili tüm araçlara erişebiliriz.

İndirdiğimiz dosyadaki exe yi açıp ilerleyebiliriz.

Açtığımız dosyada ilk olarak, obsutil için yardımcı komutlar geliyor. Bu aşamada ilk olarak login olmaya çalışacağız.

Access Key & Secret Key

OBS ya da başka servislere erişebilmemiz için, öncelike Huawei Cloud Console üzerinden access key ve secret keyleri almamız gerekiyor. Bunu ise My Credentials > Access Keys kısmından alabiliriz.

login

OBS kaynaklarına erişmek için aşağıdaki şekilde devam edebiliriz. Buradaki önemli husus endpoint in nereye bakacağı. Region bazlı gittiğimizde, sadece o region a ait kaynakları görüntüleyebiliyoruz. Aksi takdirde login olduğumuz region içerisinde bucket bulunamadı hatası alabiliriz.

Örneğin, -e obs.tr-west-1.myhuaweicloud.com

obsutil config -i <AccessKeyID> -k <SecretAccessKey> -e <Endpoint>

bucket list

Tüm bucket listesini almak için, obsutil ls şeklinde ilerleyebiliriz.

obsutil ls

ls komutu ile tüm bucket listesini görebiliriz.

dilersek bucket içerisine de girebiliriz

obsutil ls obs://<bucket-name>

create bucket

obsutil mb obs://<bucket-name> -location=tr-west-1

delete bucket

Eğer bir bucket i silmek istersek;

obsutil rm obs://<bucket-name>

şeklinde devam edebiliriz fakat eğer içeride bir data var ise bucket i silmemiz mümkün olmayacak. Burada ilk olarak bucket içeriğini silmemiz gerekecek.

Delete bucket [bucket-name] failed, status [409], error code [BucketNotEmpty], error message [The bucket you tried to delete is not empty], request id [00000194DCB4F1DD8066257B059E8A6B]

obsutil rm obs://<bucket-name> -r -f

-->obsutil ls obs://gogo123/
Listing objects .

Folder list:
obs://gogo123/test/
obs://gogo123/test3/
obs://gogo123/test34/

Total size of bucket: 0B
Folder number: 3
File number: 0

klasör bazında silmek istersek;

obsutil rm obs://<bucket-name>/<folder-name> -r -f

bucket cp

Kopyalama işlemini birden fazla şekilde yapabiliriz. Bir dosyayı kendimize çekebiliriz veya OBS e dosya gönderebiliriz ya da bucket arası kopyalama yapabiliriz.

obsutil cp <target-file.xyz> obs://<bucket-name>

Bucketlar arası taşıma için de aşağıdaki komutu kullanabiliriz. 1 >> 2 ye kopyalanır.

obsutil cp obs://<bucket-1> obs://<bucket-2> -r -f

diğer ek komutlar ise aşağıdaki şekilde;

Basic commands:
  abort         cloud_url [options...]
                abort multipart uploads

  bucketpolicy  cloud_url [options...]


  cat           cloud_url
                view the content of a text object in a bucket

  chattri       cloud_url [options...]
                set bucket or object properties

  cp            file_url cloud_url [options...]
                cloud_url file_url [options...]
                cloud_url cloud_url [options...]
                upload, download or copy objects

  create-share  cloud_url [options...]
                create authorization code for sharing

  download      resource_url file_url [options...]
                download an object directly using the specified resource url

  ls            [cloud_url] [options...]
                list buckets or objects/multipart uploads in a bucket

  mb            cloud_url [options...]
                create a bucket with the specified parameters

  mkdir         cloud_url|folder_url
                create folder(s) in a specified bucket or in the local file system

  mv            cloud_url cloud_url [options...]
                move objects

  restore       cloud_url [options...]
                restore objects in a bucket to be readable

  rm            cloud_url [options...]
                delete a bucket or objects in a bucket

  share-cp      authorization_code file_url [options...]
                download objects using authorization code and access code

  share-ls      authorization_code [options...]
                list objects using authorization code and access code

  sign          cloud_url [options...]
                generate the download url(s) for the objects in a specified bucket

  stat          cloud_url
                show the properties of a bucket or an object

  sync          file_url cloud_url [options...]
                cloud_url file_url [options...]
                cloud_url cloud_url [options...]
                synchronize objects from the source to the destination

  update        cloud_url [options...]
                update obsutil


Other commands:
  archive       [archive_url]
                archive log files to local file system or OBS

  clear         [checkpoint_dir] [options...]
                delete part records

  config        [options...]
                update the configuration file

  hash          file_url [options...]
                caculate the md5 or crc64 hash code of a local file

  help          [command]
                view command help information

  version
                show version

-r recursive, ile alt klaösrler dahil tüm dosyalar kopyalanır.

-f ile force yani onay işlemi sormadan tamamlanır.

Published inhuawei cloud

Comments are closed.