forked from docs/doc-exports
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com> Co-authored-by: weihongmin1 <weihongmin1@huawei.com> Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
47 lines
4.9 KiB
HTML
47 lines
4.9 KiB
HTML
<a name="obs_11_0030"></a><a name="obs_11_0030"></a>
|
|
|
|
<h1 class="topictitle1">Copy</h1>
|
|
<div id="body1543383727788"><p id="obs_11_0030__p11572732132917">All commands in this section use the Linux operating system as an example to describe how to copy files.</p>
|
|
<p id="obs_11_0030__p4927118201719">Assume that bucket <strong id="obs_11_0030__b203161520172217">bucket-src</strong> contains the following objects:</p>
|
|
<pre class="screen" id="obs_11_0030__screen776818585566">obs://bucket-src/test1.txt
|
|
obs://bucket-src/test2.txt
|
|
obs://bucket-src/test3.txt
|
|
obs://bucket-src/test4.txt
|
|
obs://bucket-src/test5.txt
|
|
obs://bucket-src/test6.txt
|
|
obs://bucket-src/src1/
|
|
obs://bucket-src/src1/test7.txt
|
|
obs://bucket-src/src2/
|
|
obs://bucket-src/src2/test8.txt
|
|
obs://bucket-src/src2/src3/
|
|
obs://bucket-src/src2/src3/test9.txt</pre>
|
|
<p id="obs_11_0030__p4490143842915">Based on the structure of objects in the bucket, different copy scenarios require different commands.</p>
|
|
<ul id="obs_11_0030__ul174731818476"><li id="obs_11_0030__li23391442113117">To copy the <strong id="obs_11_0030__b195901924133613">test1.txt</strong> file from bucket <strong id="obs_11_0030__b38601828143610">bucket-src</strong> to bucket <strong id="obs_11_0030__b1679284483610">bucket-dest</strong>, the command is as follows:<pre class="screen" id="obs_11_0030__screen134701607338">./obsutil cp obs://bucket-src/test1.txt obs://bucket-dest</pre>
|
|
<p id="obs_11_0030__p421814820337">After the copy is complete, the following object is generated in bucket <strong id="obs_11_0030__b54714489394">bucket-dest</strong>:</p>
|
|
<pre class="screen" id="obs_11_0030__screen24831326184214">obs://bucket-dest/test1.txt</pre>
|
|
</li><li id="obs_11_0030__li156448133217">To copy the content of the <strong id="obs_11_0030__b143881558173911">test1.txt</strong> file in bucket <strong id="obs_11_0030__b939385813916">bucket-src</strong> to the <strong id="obs_11_0030__b1688312918441">text.txt</strong> file in bucket <strong id="obs_11_0030__b5397105823910">bucket-dest</strong>, the command is as follows:<pre class="screen" id="obs_11_0030__screen35103318446">./obsutil cp obs://bucket-src/test1.txt obs://bucket-dest/test.txt</pre>
|
|
<p id="obs_11_0030__p2355435104418">After the copy is complete, the following object is generated in bucket <strong id="obs_11_0030__b9841532124517">bucket-dest</strong>:</p>
|
|
<pre class="screen" id="obs_11_0030__screen1131134814447">obs://bucket-dest/test.txt</pre>
|
|
</li><li id="obs_11_0030__li49953160445">To copy the <strong id="obs_11_0030__b778384264516">test1.txt</strong> file in bucket <strong id="obs_11_0030__b67842425459">bucket-src</strong> to the <strong id="obs_11_0030__b37851942114517">text</strong> folder in bucket <strong id="obs_11_0030__b978654213456">bucket-dest</strong>, the command is as follows:<pre class="screen" id="obs_11_0030__screen13166164513203">./obsutil cp obs://bucket-src/test1.txt obs://bucket-dest/test/</pre>
|
|
<p id="obs_11_0030__p187128417465">After the copy is complete, the following object is generated in bucket <strong id="obs_11_0030__b1620903104819">bucket-dest</strong>:</p>
|
|
<pre class="screen" id="obs_11_0030__screen1078720511468">obs://bucket-dest/test/test1.txt</pre>
|
|
</li><li id="obs_11_0030__li133851558134412">Run the following command to recursively copy the entire <strong id="obs_11_0030__b1861203810489">src2</strong> folder in bucket <strong id="obs_11_0030__b13711436124914">bucket-src</strong> to bucket <strong id="obs_11_0030__b206583811487">bucket-dest</strong> in force mode:<pre class="screen" id="obs_11_0030__screen107719526203">./obsutil cp obs://bucket-src/src2 obs://bucket-dest -r -f</pre>
|
|
<p id="obs_11_0030__p2062213345403">After the copy is complete, the following objects are generated in bucket <strong id="obs_11_0030__b116361229125017">bucket-dest</strong>:</p>
|
|
<pre class="screen" id="obs_11_0030__screen18781194620460">obs://bucket-dest/src2/
|
|
obs://bucket-dest/src2/test8.txt
|
|
obs://bucket-dest/src2/src3/
|
|
obs://bucket-dest/src2/src3/test9.txt</pre>
|
|
</li><li id="obs_11_0030__li1668483194517">To recursively copy all files and subfolders in the <strong id="obs_11_0030__b887214398506">src2</strong> folder in bucket <strong id="obs_11_0030__b9875153913503">bucket-src</strong> to bucket <strong id="obs_11_0030__b887815399507">bucket-dest</strong> in force mode, the command is as follows:<pre class="screen" id="obs_11_0030__screen18112009214">./obsutil cp obs://bucket-src/src2 obs://bucket-dest -r -f -flat</pre>
|
|
<p id="obs_11_0030__p11489103718404">After the copy is complete, the following objects are generated in bucket <strong id="obs_11_0030__b196018720517">bucket-dest</strong>:</p>
|
|
<pre class="screen" id="obs_11_0030__screen8497114114461">obs://bucket-dest/test8.txt
|
|
obs://bucket-dest/src3/
|
|
obs://bucket-dest/src3/test9.txt</pre>
|
|
</li></ul>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0027.html">Common Examples</a></div>
|
|
</div>
|
|
</div>
|
|
|