Files
doc-exports/docs/obs/tool-obsutil/obs_11_0028.html
weihongmin1 a41a4e0331 OBS Util 0115 Version
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com>
Co-authored-by: weihongmin1 <weihongmin1@huawei.com>
Co-committed-by: weihongmin1 <weihongmin1@huawei.com>
2026-02-17 10:18:57 +00:00

107 lines
10 KiB
HTML

<a name="obs_11_0028"></a><a name="obs_11_0028"></a>
<h1 class="topictitle1">Upload</h1>
<div id="body1543383727788"><p id="obs_11_0028__p12327115152214">All commands in this section use the Linux operating system as an example to describe how to upload files.</p>
<p id="obs_11_0028__p8060118">Assume that a local folder is in the following structure:</p>
<pre class="screen" id="obs_11_0028__screen1426863513468"><span style="color:#666600;">└──</span> src1
<span style="color:#666600;"> ├──</span> src2
<span style="color:#666600;"> ├──</span> test1.txt
<span style="color:#666600;"> └──</span> test2.txt
<span style="color:#666600;">├──</span> src3
<span style="color:#666600;">└──</span> test3.txt</pre>
<p id="obs_11_0028__p17877103915256">Based on the preceding folder structure, different upload scenarios require different commands.</p>
<ul id="obs_11_0028__ul65731417913"><li id="obs_11_0028__li757312411492">To upload the <strong id="obs_11_0028__b2197851144">test3.txt</strong> file in the local <strong id="obs_11_0028__b112921377146">src1</strong> folder to the root directory of bucket <strong id="obs_11_0028__b38540751513">bucket-test</strong>, the command is as follows:<pre class="screen" id="obs_11_0028__screen97071023143413">./obsutil cp /src1/test3.txt obs://bucket-test</pre>
<p id="obs_11_0028__p19189123203414">After the upload completes, the following object is generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen1493988173511">./obs://bucket-test/test3.txt</pre>
</li><li id="obs_11_0028__li35730411890">To upload the <strong id="obs_11_0028__b137212416161">test3.txt</strong> file in the local <strong id="obs_11_0028__b275132415166">src1</strong> folder to the root directory of bucket <strong id="obs_11_0028__b37762414162">bucket-test</strong> and rename it to <strong id="obs_11_0028__b178862174171">aaa.txt</strong>, the command is as follows:<pre class="screen" id="obs_11_0028__screen960762624417">./obsutil cp /src1/test3.txt obs://bucket-test/aaa.txt</pre>
<p id="obs_11_0028__p16543202916444">After the upload completes, the following object is generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen15482115134419">./obs://bucket-test/aaa.txt</pre>
</li><li id="obs_11_0028__li1057354116912">To upload the <strong id="obs_11_0028__b986263041720">test3.txt</strong> file in the local <strong id="obs_11_0028__b14865123015176">src1</strong> folder to the <strong id="obs_11_0028__b322232241816">src</strong> folder in bucket <strong id="obs_11_0028__b2867123071715">bucket-test</strong>, the command is as follows:<pre class="screen" id="obs_11_0028__screen1925185964516">./obsutil cp /src1/test3.txt obs://bucket-test/src/</pre>
<p id="obs_11_0028__p78768120461">After the upload completes, the following object is generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen123251322154610">./obs://bucket-test/src/test3.txt</pre>
</li><li id="obs_11_0028__li55739411691">To recursively upload the entire local <strong id="obs_11_0028__b318920179194">src2</strong> folder to the root directory of bucket <strong id="obs_11_0028__b27287475225">bucket-test</strong> in force mode, the command is as follows:<pre class="screen" id="obs_11_0028__screen13999192254816">./obsutil cp /src1/src2 obs://bucket-test -r -f</pre>
<p id="obs_11_0028__p448583494818">After the upload completes, the following objects are generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen114981544114811">obs://bucket-test/src2/
obs://bucket-test/src2/test1.txt
obs://bucket-test/src2/test2.txt</pre>
</li><li id="obs_11_0028__li4573134118920">To recursively upload the entire local <strong id="obs_11_0028__b04415293278">src1</strong> folder to the <strong id="obs_11_0028__b15883817152812">src</strong> folder in bucket <strong id="obs_11_0028__b1444442917271">bucket-test</strong> in force mode, the command is as follows:<pre class="screen" id="obs_11_0028__screen583411509104">./obsutil cp /src1 obs://bucket-test/src -r -f</pre>
<p id="obs_11_0028__p15323162710105">After the upload completes, the following objects are generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen149581934141019">obs://bucket-test/src/src1/
obs://bucket-test/src/src1/src2/
obs://bucket-test/src/src1/src2/test1.txt
obs://bucket-test/src/src1/src2/test2.txt
obs://bucket-test/src/src1/src3/
obs://bucket-test/src/src1/test3.txt</pre>
</li><li id="obs_11_0028__li1357310411914">To recursively upload the all files and subfolders in the local <strong id="obs_11_0028__b1313313602818">src1</strong> folder to the <strong id="obs_11_0028__b313423662813">src</strong> folder in bucket <strong id="obs_11_0028__b613513619282">bucket-test</strong> in force mode, the command is as follows:<pre class="screen" id="obs_11_0028__screen1359032111119">./obsutil cp /src1 obs://bucket-test/src -r -f -flat</pre>
<p id="obs_11_0028__p121271656496">After the upload completes, the following objects are generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen9749104014106">obs://bucket-test/src/
obs://bucket-test/src/src2/
obs://bucket-test/src/src2/test1.txt
obs://bucket-test/src/src2/test2.txt
obs://bucket-test/src/src3/
obs://bucket-test/src/test3.txt</pre>
</li><li id="obs_11_0028__li1763215581321">To upload the <strong id="obs_11_0028__b2560161913219">file1</strong> file to the <strong id="obs_11_0028__b25216326210">bucket-test</strong> bucket, and resume the upload if the upload fails, run the following commands:<pre class="screen" id="obs_11_0028__screen1993515139149">./obsutil cp /file1 obs://bucket-test/file -f</pre>
<p id="obs_11_0028__p1274123318144">The upload fails. The command output is as follows:</p>
<pre class="screen" id="obs_11_0028__screen96275241911"><strong id="obs_11_0028__b35758137149">./obsutil cp /file1 obs://bucket-test/file</strong> -f
Parallel: 3 Jobs: 3
Threshold: 524288000 PartSize: 5242880
VerifyLength: false VerifyMd5: false
CheckpointDir: xxxx
[=================================__________________] 66.08% ?/s 3.35GB/4.88GB ?</pre>
<p id="obs_11_0028__p589795251920">Run the preceding command again to resume the upload. The command output is as follows:</p>
<pre class="screen" id="obs_11_0028__screen442524122"><strong id="obs_11_0028__b942102411215">obsutil cp /file1 obs://bucket-test/file</strong> -f</pre>
<pre class="screen" id="obs_11_0028__screen1689745241914">Parallel: 3 Jobs: 3
Threshold: 524288000 PartSize: 5242880
VerifyLength: false VerifyMd5: false
CheckpointDir: xxxx
[====================================================] 100% 307.42MB/s 4.88GB/4.88GB 5.308s
Upload successfully, 4.88GB, n/a, /file1 --&gt; obs://bucket-test/file, cost [6325], status [200], request id [xxxxx]</pre>
</li><li id="obs_11_0028__li204025347139">To incrementally upload all files from the local <strong id="obs_11_0028__b2008360290">src1</strong> folder to the <strong id="obs_11_0028__b18465481662">src</strong> directory of bucket <strong id="obs_11_0028__b267945270">bucket-test</strong>, the command is as follows:<pre class="screen" id="obs_11_0028__screen429204818613">./obsutil cp /src1 obs://bucket-test/src -f -r -u</pre>
<p id="obs_11_0028__p3867257142218">Four objects are successfully uploaded, one of which is a new object. The command output contains <strong id="obs_11_0028__b2080320211075">Skip count</strong>.</p>
<pre class="screen" id="obs_11_0028__screen711816312237"><strong id="obs_11_0028__b71191310232">./obsutil cp /src1 obs://bucket-test/src</strong> -f -r -u</pre>
<pre class="screen" id="obs_11_0028__screen31198314233">Start at 2024-10-08 02:00:18.8906532 +0000 UTC
Parallel: 5 Jobs: 5
Threshold: 50.00MB PartSize: auto
VerifyLength: false VerifyMd5: false
CheckpointDir: xxxx
Task id: 6a97974a-7929-4188-9736-fcd637d16584
OutputDir: xxxx
[====================================================] 100% tps:0.00 ?/s 2.09KB/2.09KB 5ms
Succeed count: 4 Failed count: 0 Skip count: 3
Succeed bytes: 2.09KB
Metrics [max cost:6 ms, min cost:6 ms, average cost:1.50 ms, average tps:52.63, transferred size :2.09KB]</pre>
</li><li id="obs_11_0028__li2897203195717">Run the following command to exclude the <strong id="obs_11_0028__b1062322135120">src2</strong> folder (including all files and folders contained) when uploading the <strong id="obs_11_0028__b10131656185417">src1</strong> folder:<pre class="screen" id="obs_11_0028__screen862914360547">./obsutil cp /src1 obs://bucket-test/src -exclude "*src1/src2*" -f -r -mf</pre>
<p id="obs_11_0028__p1167442118577">Five objects are successfully uploaded, and the upload information contains <strong id="obs_11_0028__b198807291512">exclude</strong> and the specific content.</p>
<pre class="screen" id="obs_11_0028__screen1431438135811">./obsutil cp /src1 obs://bucket-test/src -exclude "*src1/src2*" -f -r -mf
Start at 2024-10-08 02:04:27.7752009 +0000 UTC
Parallel: 5 Jobs: 5
Threshold: 50.00MB PartSize: auto
VerifyLength: false VerifyMd5: false
Exclude: *src1/src2*
Include:
CheckpointDir: xxxx
OutputDir: xxxx
[====================================================] 100.00% tps:35.82 ?/s 5/5 2.39KB/2.39KB 340ms
Succeed count: 3 Failed count: 0
Succeed bytes: 2.39KB
Metrics [max cost:338 ms, min cost:91 ms, average cost:240.40 ms, average tps:14.62, transferred size:2.39KB]</pre>
<p id="obs_11_0028__p132131649489">After the upload completes, the following objects are generated in the bucket:</p>
<pre class="screen" id="obs_11_0028__screen1821314916811">obs://bucket-test/src/src1/
obs://bucket-test/src/src1/src3/
obs://bucket-test/src/src1/test3.txt</pre>
</li></ul>
<div class="note" id="obs_11_0028__note5861456145416"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="obs_11_0028__p330575518551">Resumable upload is available only for large files. Specifically, the file size is greater than 5 GB or the file size is greater than the threshold (50 MB by default).</p>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_11_0027.html">Common Examples</a></div>
</div>
</div>