github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/docs/cli/object.md (about) 1 --- 2 layout: post 3 title: OBJECT 4 permalink: /docs/cli/object 5 redirect_from: 6 - /cli/object.md/ 7 - /docs/cli/object.md/ 8 --- 9 10 # CLI Reference for Objects 11 This document contains `ais object` commands - the commands to read (GET), write (PUT), APPEND, PROMOTE, PREFETCH, EVICT etc. user data. 12 13 Namely: 14 15 ```console 16 $ ais object <TAB-TAB> 17 18 get put cp set-custom show rm 19 ls promote concat evict mv cat 20 ``` 21 22 ## Table of Contents 23 - [GET object](#get-object) 24 - [Save object to local file](#save-object-to-local-file) 25 - [Save object to local file with implied file name](#save-object-to-local-file-with-implied-file-name) 26 - [Get object and print it to standard output](#get-object-and-print-it-to-standard-output) 27 - [Check if object is _cached_](#check-if-object-is-cached) 28 - [Read range](#read-range) 29 - [GET multiple objects](#get-multiple-objects) 30 - [GET archived content](#get-archived-content) 31 - [Print object content](#print-object-content) 32 - [Show object properties](#show-object-properties) 33 - [Out of band updates](/docs/out_of_band.md) 34 - [PUT object](#put-object) 35 - [Object names](#object-names) 36 - [Put single file](#put-single-file) 37 - [Put single file with checksum](#put-single-file-with-checksum) 38 - [Put single file with implicitly defined name](#put-single-file-with-implicitly-defined-name) 39 - [Put content from STDIN](#put-content-from-stdin) 40 - [Put directory](#put-directory) 41 - [Put multiple files with prefix added to destination object names](#put-multiple-files-with-prefix-added-to-destination-object-names) 42 - [PUT multiple files into virtual directory, track progress](#put-multiple-files-into-virtual-directory-track-progress) 43 - [Put pattern-matching files from directory](#put-pattern-matching-files-from-directory) 44 - [Put a range of files](#put-a-range-of-files) 45 - [Put a list of files](#put-a-list-of-files) 46 - [Dry-Run option](#dry-run-option) 47 - [Put multiple directories](#put-multiple-directories) 48 - [Put multiple directories with the `--skip-vc` option](#put-multiple-directories-with-the-skip-vc-option) 49 - [APPEND object](#append-object) 50 - [Delete object](#delete-object) 51 - [Evict object](#evict-object) 52 - [Promote files and directories](#promote-files-and-directories) 53 - [Move object](#move-object) 54 - [Concat objects](#concat-objects) 55 - [Set custom properties](#set-custom-properties) 56 - [Operations on Lists and Ranges](#operations-on-lists-and-ranges) 57 - [Prefetch objects](#prefetch-objects) 58 - [Delete multiple objects](#delete-multiple-objects) 59 - [Evict multiple objects](#evict-multiple-objects) 60 61 # GET object 62 63 Use `ais object get` or, same, `ais get` to GET data from aistore. In other words, read data from the cluster and, optionally, save it locally. 64 65 `ais get [command options] BUCKET[/OBJECT_NAME] [OUT_FILE|-]` 66 67 there's 68 69 * a bucket source with an optional object name (`BUCKET[/OBJECT_NAME]`), and 70 * destination (but also optional) `[OUT_FILE]` or standard output (`-`) 71 72 Here's in detail: 73 74 ```console 75 $ ais get --help 76 77 NAME: 78 ais get - (alias for "object get") get an object, a shard, an archived file, or a range of bytes from all of the above; 79 write the content locally with destination options including: filename, directory, STDOUT ('-'), or '/dev/null' (discard); 80 assorted options further include: 81 - '--prefix' to get multiple objects in one shot (empty prefix for the entire bucket); 82 - '--extract' or '--archpath' to extract archived content; 83 - '--progress' and '--refresh' to watch progress bar; 84 - '-v' to produce verbose output when getting multiple objects. 85 86 USAGE: 87 ais get [command options] BUCKET[/OBJECT_NAME] [OUT_FILE|OUT_DIR|-] 88 89 OPTIONS: 90 --offset value object read offset; must be used together with '--length'; default formatting: IEC (use '--units' to override) 91 --length value object read length; default formatting: IEC (use '--units' to override) 92 --checksum validate checksum 93 --yes, -y assume 'yes' to all questions 94 --check-cached check whether a given named object is present in cluster 95 (applies only to buckets with remote backend) 96 --latest check in-cluster metadata and, possibly, GET, download, prefetch, or copy the latest object version 97 from the associated remote bucket: 98 - provides operation-level control over object versioning (and version synchronization) 99 without requiring to change bucket configuration 100 - the latter can be done using 'ais bucket props set BUCKET versioning' 101 - see also: 'ais ls --check-versions', 'ais cp', 'ais prefetch', 'ais get' 102 --refresh value interval for continuous monitoring; 103 valid time units: ns, us (or µs), ms, s (default), m, h 104 --progress show progress bar(s) and progress of execution in real time 105 --blob-download utilize built-in blob-downloader (and the corresponding alternative datapath) to read very large remote objects 106 --chunk-size value chunk size in IEC or SI units, or "raw" bytes (e.g.: 4mb, 1MiB, 1048576, 128k; see '--units') 107 --num-workers value number of concurrent blob-downloading workers (readers); system default when omitted or zero (default: 0) 108 --archpath value extract the specified file from an object ("shard") formatted as: .tar, .tgz or .tar.gz, .zip, .tar.lz4; 109 see also: '--archregx' 110 --archmime value expected format (mime type) of an object ("shard") formatted as: .tar, .tgz or .tar.gz, .zip, .tar.lz4; 111 especially usable for shards with non-standard extensions 112 --archregx value prefix, suffix, WebDataset key, or general-purpose regular expression to select possibly multiple matching archived files; 113 use '--archmode' to specify the "matching mode" (that can be prefix, suffix, WebDataset key, or regex) 114 --archmode value enumerated "matching mode" that tells aistore how to handle '--archregx', one of: 115 * regexp - general purpose regular expression; 116 * prefix - matching filename starts with; 117 * suffix - matching filename ends with; 118 * substr - matching filename contains; 119 * wdskey - WebDataset key, e.g.: 120 example: 121 given a shard containing (subdir/aaa.jpg, subdir/aaa.json, subdir/bbb.jpg, subdir/bbb.json, ...) 122 and wdskey=subdir/aaa, aistore will match and return (subdir/aaa.jpg, subdir/aaa.json) 123 --extract, -x extract all files from archive(s) 124 --inventory list objects using _bucket inventory_ (docs/s3inventory.md); requires s3:// backend; will provide significant performance 125 boost when used with very large s3 buckets; e.g. usage: 126 1) 'ais ls s3://abc --inventory' 127 2) 'ais ls s3://abc --inventory --paged --prefix=subdir/' 128 (see also: docs/s3inventory.md) 129 --inv-name value bucket inventory name (optional; system default name is '.inventory') 130 --inv-id value bucket inventory ID (optional; by default, we use bucket name as the bucket's inventory ID) 131 --prefix value get objects that start with the specified prefix, e.g.: 132 '--prefix a/b/c' - get objects from the virtual directory a/b/c and objects from the virtual directory 133 a/b that have their names (relative to this directory) starting with 'c'; 134 '--prefix ""' - get entire bucket (all objects) 135 --cached get only in-cluster objects - only those objects from a remote bucket that are present ("cached") 136 --archive list archived content (see docs/archive.md for details) 137 --limit value maximum number of object names to display (0 - unlimited; see also '--max-pages') 138 e.g.: 'ais ls gs://abc --limit 1234 --cached --props size,custom (default: 0) 139 --units value show statistics and/or parse command-line specified sizes using one of the following _units of measurement_: 140 iec - IEC format, e.g.: KiB, MiB, GiB (default) 141 si - SI (metric) format, e.g.: KB, MB, GB 142 raw - do not convert to (or from) human-readable format 143 --verbose, -v verbose output 144 --silent server-side flag, an indication for aistore _not_ to log assorted errors (e.g., HEAD(object) failures) 145 --help, -h show help 146 ``` 147 148 ## Save object to local file 149 150 Get the `imagenet_train-000010.tgz` object from the `imagenet` bucket and write it to a local file, `~/train-10.tgz`: 151 152 ```console 153 $ ais get ais://imagenet/imagenet_train-000010.tgz ~/train-10.tgz 154 GET "imagenet_train-000010.tgz" from bucket "imagenet" as "/home/user/train-10.tgz" [946.8MiB] 155 ``` 156 157 For comparison, the same GET using `curl` and [the two supported variants of RESTful API](/docs/http_api.md): 158 159 ```console 160 # 1. curl GET using conventional RESTful API 161 # (`aistore` in the URL is a host that runs any AIStore gateway that can be specified via `AIS_ENDPOINT` environment): 162 163 $ curl -L -X GET 'http://aistore/v1/objects/imagenet/magenet_train-000010.tgz?provider=gs -o ~/train-10.tgz' 164 165 # 2. and the same using "easy URL": 166 167 $ curl -L -X GET 'http://aistore/ais/imagenet/magenet_train-000010.tgz -o ~/train-10.tgz' 168 ``` 169 170 ## Save object to local file with implied file name 171 172 If `OUT_FILE` is omitted, the local file name is implied from the object name. 173 174 Get the `imagenet_train-000010.tgz` object from the `imagenet` bucket and write it to a local file, `imagenet_train-000010.tgz`: 175 176 ```console 177 $ ais get imagenet/imagenet_train-000010.tgz 178 GET "imagenet_train-000010.tgz" from bucket "imagenet" as "imagenet_train-000010.tgz" [946.8MiB] 179 ``` 180 181 ## Get object and print it to standard output 182 183 Get the `imagenet_train-000010.tgz` object from the `imagenet` AWS bucket and write it to standard output: 184 185 ```console 186 $ ais get aws://imagenet/imagenet_train-000010.tgz - 187 ``` 188 189 ## Check if object is _cached_ 190 191 We say that "an object is _cached_" to indicate two separate things: 192 193 * The object was originally downloaded from a remote (e.g., 3rd party Cloud) bucket, a bucket in a remote AIS cluster, or a HTTP(s) based dataset; 194 * The object is stored in the AIS cluster. 195 196 In other words, the term "cached" is simply a **shortcut** to indicate the object's immediate availability without the need to go to the object's original location. 197 Being "cached" does not have any implications on an object's persistence: "cached" objects, similar to objects that originated in a given AIS cluster, are stored with arbitrary (per bucket configurable) levels of redundancy, etc. In short, the same storage policies apply to "cached" and "non-cached". 198 199 The following example checks whether `imagenet_train-000010.tgz` is "cached" in the bucket `imagenet`: 200 201 ```console 202 $ ais get --cached ais://imagenet/imagenet_train-000010.tgz 203 Cached: true 204 ``` 205 206 ## Read range 207 208 Get the contents of object `list.txt` from `texts` bucket starting from offset `1024` length `1024` and save it as `~/list.txt` file: 209 210 ```console 211 $ ais get --offset 1024 --length 1024 ais://texts/list.txt ~/list.txt 212 Read 1.00KiB (1024 B) 213 ``` 214 215 ### Example: read-range multiple objects 216 217 Let's say, bucket ais://src contains 4 copies of [aistore readme](https://github.com/NVIDIA/aistore/blob/main/README.md) in its virtual directory `docs/`: 218 219 The following reads 10 bytes from each copy and prints the result: 220 221 ```console 222 $ ais get ais://src --prefix "docs/" --offset 0 --length 10 - 223 Read range 4 objects from ais://src to standard output (total size 50.23KiB) [Y/N]: y 224 225 **AIStore **AIStore **AIStore **AIStore $ 226 ``` 227 228 Same as above with automatic confirmation and writing results to `/tmp/w`: 229 230 ```console 231 $ ais get ais://src --prefix "docs/" --offset 0 --length 10 /tmp/w -y 232 233 $ ls -al /tmp/w | awk '{print $5,$9}' 234 235 10 README.md 236 10 copy1.md 237 10 copy2.md 238 10 copy3.md 239 ``` 240 241 # GET multiple objects 242 243 Note that destination in this case is a local directory and that (an empty) prefix indicates getting entire bucket; see `--help` for details. 244 245 ```console 246 $ ais get s3://abc /tmp/w --prefix "" --progress 247 GET 60 objects from s3://abc to /tmp/w (size 92.47MiB) [Y/N]: y 248 Objects: 59/60 [============================================================>-] 98 % 249 Total size: 63.00 MiB / 92.47 MiB [=========================================>--------------------] 68 % 250 ``` 251 252 # GET archived content 253 254 For objects formatted as (.tar, .tar.gz, .tar.lz4, or .zip), it is possible to GET and extract them in one shot. There are two "responsible" options: 255 256 | Name | Description | 257 | --- | --- | 258 | `--archpath` | extract the specified file from an archive (shard) | 259 | `--extract` | extract all files from archive(s) | 260 261 Maybe the most basic: 262 263 ### Example: extracting one file using its fully-qualified name:: 264 265 ```console 266 $ ais get ais://nnn/A.tar/tutorials/README.md /tmp/out --archive 267 ``` 268 269 > assuming, ais://nnn/A.tar was previously created via (e.g.) `ais archive put docs ais://nnn/A.tar -r` 270 271 ## Example: extract all files from all shards with a given prefix 272 273 Let's say, there's a bucket `ais://dst` with a virtual directory `abc/` that in turn contains: 274 275 ```console 276 $ ais ls ais://dst --prefix abc/ 277 NAME SIZE 278 abc/A.tar.gz 5.18KiB 279 abc/B.tar.lz4 247.88KiB 280 abc/C.tar.zip 4.15KiB 281 abc/D.tar 2.00KiB 282 ``` 283 284 Next, we GET and extract them all in the respective sub-directories (note also the `--verbose` option): 285 286 ```console 287 $ ais get ais://dst /tmp/w --prefix "abc/" --extract -v 288 289 GET 4 objects from ais://dst to /tmp/w (total size 259.21KiB) [Y/N]: y 290 GET D.tar from ais://dst as "/tmp/w/D.tar" (2.00KiB) and extract as /tmp/w/D 291 GET A.tar.gz from ais://dst as "/tmp/w/A.tar.gz" (5.18KiB) and extract as /tmp/w/A 292 GET C.tar.zip from ais://dst as "/tmp/w/C.tar.zip" (4.15KiB) and extract as /tmp/w/C 293 GET B.tar.lz4 from ais://dst as "/tmp/w/B.tar.lz4" (247.88KiB) and extract as /tmp/w/B 294 ``` 295 296 ### Example: use '--prefix' that crosses shard boundary 297 298 For starters, we recursively archive all aistore docs: 299 300 ```console 301 $ ais put docs ais://A.tar --archive -r 302 ``` 303 304 To list a virtual subdirectory _inside_ this newly created shard (e.g.): 305 306 ```console 307 $ ais archive ls ais://nnn --prefix A.tar/tutorials 308 NAME SIZE 309 A.tar/tutorials/README.md 561B 310 A.tar/tutorials/etl/compute_md5.md 8.28KiB 311 A.tar/tutorials/etl/etl_imagenet_pytorch.md 4.16KiB 312 A.tar/tutorials/etl/etl_webdataset.md 3.97KiB 313 Listed: 4 names 314 ``` 315 316 Now, extract matching files _from_ the bucket to /tmp/out: 317 318 ```console 319 $ ais get ais://nnn --prefix A.tar/tutorials /tmp/out --archive 320 GET 6 objects from ais://nnn/tmp/out (total size 17.81MiB) [Y/N]: y 321 322 $ ls -al /tmp/out/tutorials/ 323 total 20 324 drwxr-x--- 4 root root 4096 May 13 20:05 ./ 325 drwxr-xr-x 3 root root 4096 May 13 20:05 ../ 326 drwxr-x--- 2 root root 4096 May 13 20:05 etl/ 327 -rw-r--r-- 1 root root 561 May 13 20:05 README.md 328 drwxr-x--- 2 root root 4096 May 13 20:05 various/ 329 ``` 330 331 The result: 332 ```console 333 $ tree /tmp/out 334 /tmp/out 335 ├── A.tar 336 └── tutorials 337 ├── etl 338 │ ├── compute_md5.md 339 │ ├── etl_imagenet_pytorch.md 340 │ └── etl_webdataset.md 341 ├── README.md 342 └── etl 343 └── compute_md5.md 344 └── etl_imagenet_pytorch.md 345 └── etl_webdataset.md 346 ``` 347 348 > **NOTE:** for more "archival" options and examples, please see [docs/cli/archive.md](archive.md). 349 350 # Print object content 351 352 `ais object cat BUCKET/OBJECT_NAME` 353 354 Get `OBJECT_NAME` from bucket `BUCKET` and print it to standard output. 355 Alias for `ais get BUCKET/OBJECT_NAME -`. 356 357 ## Options 358 359 | Flag | Type | Description | Default | 360 | --- | --- | --- | --- | 361 | `--offset` | `string` | Read offset, which can end with size suffix (k, MB, GiB, ...) | `""` | 362 | `--length` | `string` | Read length, which can end with size suffix (k, MB, GiB, ...) | `""` | 363 | `--checksum` | `bool` | Validate the checksum of the object | `false` | 364 365 ## Print content of object 366 367 Print content of `list.txt` from local bucket `texts` to the standard output: 368 369 ```console 370 $ ais object cat ais://texts/list.txt 371 ``` 372 373 ## Read range 374 375 Print content of object `list.txt` starting from offset `1024` length `1024` to the standard output: 376 377 ```console 378 $ ais object cat ais://texts/list.txt --offset 1024 --length 1024 379 ``` 380 381 # Show object properties 382 383 `ais object show [--props PROP_LIST] BUCKET/OBJECT_NAME` 384 385 Get object detailed information. 386 `PROP_LIST` is a comma-separated list of properties to display. 387 If `PROP_LIST` is omitted, default properties are shown. 388 389 Supported properties: 390 391 - `cached` - the object cached on local drives (always `true` for AIS buckets) 392 - `size` - object size 393 - `version` - object version (empty if versioning is disabled for the bucket) 394 - `atime` - object's last access time 395 - `copies` - the number of object replicas per target (`1` if bucket mirroring is disabled), and mountpath where object and its mirrors are located 396 - `checksum` - object's checksum 397 - `node` - on which target the object is located 398 - `ec` - object's EC info (empty if EC is disabled for the bucket, if EC is enabled it looks like `DATA:PARITY[MODE]`, where `DATA` - the number of data slices, 399 `PARITY` - the number of parity slices, and `MODE` is protection mode selected for the object: `replicated` - object has `PARITY` replicas on other targets, 400 `encoded` the object is erasure coded and other targets contains only encoded slices 401 402 > `ais object show` is an for `ais object show` - both can be used interchangeably. 403 404 ## Show default object properties 405 406 Display default properties of object `list.txt` from bucket `texts`: 407 408 ```console 409 $ ais object show ais://texts/list.txt 410 PROPERTY VALUE 411 checksum 2d61e9b8b299c41f 412 size 7.63MiB 413 atime 06 Jan 20 14:55 PST 414 version 1 415 ``` 416 417 ## Show all object properties 418 419 Display all properties of object `list.txt` from bucket `texts`: 420 421 ```console 422 $ ais object show ais://texts/list.txt --props=all 423 PROPERTY VALUE 424 atime 06 Jan 20 14:55 PST 425 checksum 2d61e9b8b299c41f 426 copies 1 [/data/mp1] 427 custom - 428 ec 1:1[replicated] 429 name provider://texts/list.txt 430 node t[neft8086] 431 size 7.63MiB 432 version 2 433 ``` 434 435 ## Show selected object properties 436 437 Show only selected (`size,version,ec`) properties: 438 439 ```console 440 $ ais object show --props size,version,ec ais://texts/listx.txt 441 PROPERTY VALUE 442 size 7.63MiB 443 version 1 444 ec 2:2[replicated] 445 ``` 446 447 # PUT object 448 449 Briefly: 450 451 `ais put [command options] [-|FILE|DIRECTORY[/PATTERN]] BUCKET[/OBJECT_NAME_or_PREFIX]`<sup>[1](#ft1)</sup> 452 453 writes a single file, an entire directory (of files), or a typed content directly from STDIN (`-`) - into the specified (destination) bucket. 454 455 Notice the optional `[/PATTERN]` - a regular shell filename-matching primitive - to select files from the source directory. 456 457 If an object of the same name exists, the object will be overwritten without confirmation 458 459 > but only if is different, content-wise - writing identical bits is optimized-out 460 461 If CLI detects that a user is going to put more than one file, it calculates the total number of files, total data size, and checks if the bucket is empty. 462 463 Then it shows all gathered info to the user and asks for confirmation to continue. 464 465 Confirmation request can be disabled with the option `--yes` for use in scripts. 466 467 When writing from `STDIN`, type Ctrl-D to terminate the input. 468 469 ## Inline help 470 471 ```console 472 $ ais put --help 473 NAME: 474 ais put - (alias for "object put") PUT or APPEND one file, one directory, or multiple files and/or directories. 475 Use optional shell filename PATTERN (wildcard) to match/select multiple sources. 476 Destination naming is consistent with 'ais object promote' command, whereby the optional OBJECT_NAME_or_PREFIX 477 becomes either a name, a prefix, or a virtual destination directory (if it ends with a forward '/'). 478 Assorted examples and usage options follow (and see docs/cli/object.md for more): 479 - upload matching files: 'ais put "docs/*.md" ais://abc/markdown/' 480 - (notice quotation marks and a forward slash after 'markdown/' destination); 481 - '--compute-checksum': use '--compute-checksum' to facilitate end-to-end protection; 482 - '--progress': progress bar, to show running counts and sizes of uploaded files; 483 - Ctrl-D: when writing directly from standard input use Ctrl-D to terminate; 484 - '--dry-run': see the results without making any changes. 485 Notes: 486 - to write or append to (.tar, .tgz or .tar.gz, .zip, .tar.lz4)-formatted objects ("shards"), use 'ais archive' 487 488 USAGE: 489 ais put [command options] [-|FILE|DIRECTORY[/PATTERN]] BUCKET[/OBJECT_NAME_or_PREFIX] 490 491 OPTIONS: 492 --list value comma-separated list of object or file names, e.g.: 493 --list 'o1,o2,o3' 494 --list "abc/1.tar, abc/1.cls, abc/1.jpeg" 495 or, when listing files and/or directories: 496 --list "/home/docs, /home/abc/1.tar, /home/abc/1.jpeg" 497 --template value template to match object or file names; may contain prefix (that could be empty) with zero or more ranges 498 (with optional steps and gaps), e.g.: 499 --template "" # (an empty or '*' template matches eveything) 500 --template 'dir/subdir/' 501 --template 'shard-{1000..9999}.tar' 502 --template "prefix-{0010..0013..2}-gap-{1..2}-suffix" 503 and similarly, when specifying files and directories: 504 --template '/home/dir/subdir/' 505 --template "/abc/prefix-{0010..9999..2}-suffix" 506 --wait wait for an asynchronous operation to finish (optionally, use '--timeout' to limit the waiting time) 507 --timeout value maximum time to wait for a job to finish; if omitted: wait forever or until Ctrl-C; 508 valid time units: ns, us (or µs), ms, s (default), m, h 509 --progress show progress bar(s) and progress of execution in real time 510 --refresh value interval for continuous monitoring; 511 valid time units: ns, us (or µs), ms, s (default), m, h 512 --chunk-size value chunk size in IEC or SI units, or "raw" bytes (e.g.: 1MiB or 1048576; see '--units') 513 --conc value limits number of concurrent put requests and number of concurrent shards created (default: 10) 514 --dry-run preview the results without really running the action 515 --recursive, -r recursive operation 516 --verbose, -v verbose output 517 --yes, -y assume 'yes' to all questions 518 --cont-on-err keep running archiving xaction (job) in presence of errors in a any given multi-object transaction 519 --units value show statistics and/or parse command-line specified sizes using one of the following _units of measurement_: 520 iec - IEC format, e.g.: KiB, MiB, GiB (default) 521 si - SI (metric) format, e.g.: KB, MB, GB 522 raw - do not convert to (or from) human-readable format 523 --skip-vc skip loading object metadata (and the associated checksum & version related processing) 524 --compute-checksum [end-to-end protection] compute client-side checksum configured for the destination bucket 525 and provide it as part of the PUT request for subsequent validation on the server side 526 --crc32c value compute client-side crc32c checksum 527 and provide it as part of the PUT request for subsequent validation on the server side 528 --md5 value compute client-side md5 checksum 529 and provide it as part of the PUT request for subsequent validation on the server side 530 --sha256 value compute client-side sha256 checksum 531 and provide it as part of the PUT request for subsequent validation on the server side 532 --sha512 value compute client-side sha512 checksum 533 and provide it as part of the PUT request for subsequent validation on the server side 534 --xxhash value compute client-side xxhash checksum 535 and provide it as part of the PUT request for subsequent validation on the server side 536 537 ``` 538 539 <a name="ft1">1</a> `FILE|DIRECTORY` should point to a file or a directory. Wildcards are supported, but they work a bit differently from shell wildcards. 540 Symbols `*` and `?` can be used only in a file name pattern. Directory names cannot include wildcards. Only a file name is matched, not full file path, so `/home/user/*.tar --recursive` matches not only `.tar` files inside `/home/user` but any `.tar` file in any `/home/user/` subdirectory. 541 This makes shell wildcards like `**` redundant, and the following patterns won't work in `ais`: `/home/user/img-set-*/*.tar` or `/home/user/bck/**/*.tar.gz` 542 543 `FILE` must point to an existing file. 544 File masks and directory uploading are NOT supported in single-file upload mode. 545 546 ## Object names 547 548 PUT command handles two possible ways to specify resulting object name if source references single file: 549 1. Object name is not provided: `ais put path/to/(..)/file.go bucket/` creates object `file.go` in `bucket` 550 2. Explicit object name is provided: `ais put path/to/(..)/file.go bucket/path/to/object.go` creates object `path/to/object.go` in `bucket` 551 552 PUT command handles object naming with range syntax as follows: 553 - Object names are file paths without longest common prefix of all files from source. 554 This means that the leading part of file path until the last `/` before first `{` is excluded from object name. 555 - `OBJECT_NAME` is prepended to each object name. 556 - Abbreviations in source like `../` are not supported at the moment. 557 558 PUT command handles object naming if its source references directories: 559 - For path `p` of source directory, resulting objects names are path to files with trimmed `p` prefix 560 - `OBJECT_NAME` is prepended to each object name. 561 - Abbreviations in source like `../` are not supported at the moment. 562 563 All **examples** below put into an empty bucket and the source directory structure is: 564 565 ``` 566 /home/user/bck/img1.tar 567 /home/user/bck/img2.zip 568 /home/user/bck/extra/img1.tar 569 /home/user/bck/extra/img3.zip 570 ``` 571 572 The current user HOME directory is `/home/user`. 573 574 ## Put single file 575 576 First, compare two simple examples: 577 578 ```console 579 $ ais put README.md ais://nnn/ccc/ 580 PUT "README.md" => ais://nnn/ccc/README.md 581 582 $ ais put README.md ais://nnn/ccc 583 PUT "README.md" => ais://nnn/ccc 584 ``` 585 586 In other words, a **trailing forward slash** in the destination name is interpreted as a destination directory 587 588 > which is what one would expect from something like Bash: `cp README.md /nnn/ccc/` 589 590 One other example: put a single file `img1.tar` into local bucket `mybucket`, name it `img-set-1.tar`. 591 592 ```console 593 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar 594 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 595 ``` 596 597 ## Put single file with checksum 598 599 Put a single file `img1.tar` into local bucket `mybucket`, with a content checksum flag 600 to override the default bucket checksum performed at the server side. 601 602 ```console 603 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --crc32c 0767345f 604 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 605 606 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --md5 e91753513c7fc873467c1f3ca061fa70 607 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 608 609 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --sha256 dc2bac3ba773b7bc52c20aa85e6ce3ae097dec870e7b9bda03671a1c434b7a5d 610 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 611 612 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --sha512 e7da5269d4cd882deb8d7b7ca5cbf424047f56815fd7723123482e2931823a68d866627a449a55ca3a18f9c9ba7c8bb6219a028ba3ff5a5e905240907d087e40 613 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 614 615 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --xxhash 05967d5390ac53b0 616 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 617 ``` 618 619 Optionally, the user can choose to provide a `--compute-cksum` flag for the checksum flag and 620 let the API take care of the computation. 621 622 ```console 623 $ ais put "/home/user/bck/img1.tar" ais://mybucket/img-set-1.tar --compute-cksum 624 # PUT /home/user/bck/img1.tar => ais://mybucket/img-set-1.tar 625 ``` 626 627 ## Put single file with implicitly defined name 628 629 Put a single file `~/bck/img1.tar` into bucket `mybucket`, without explicit name. 630 631 ```console 632 $ ais put "~/bck/img1.tar" ais://mybucket/ 633 634 # PUT /home/user/bck/img1.tar => mybucket/img-set-1.tar 635 ``` 636 637 ## Put content from STDIN 638 639 Read unpacked content from STDIN and put it into bucket `mybucket` with name `img-unpacked`. 640 641 Note that content is put in chunks that can have a slight overhead. 642 `--chunk-size` allows for controlling the chunk size - the bigger the chunk size the better performance (but also higher memory usage). 643 644 ```bash 645 $ tar -xOzf ~/bck/img1.tar | ais put - ais://mybucket/img1-unpacked 646 # PUT /home/user/bck/img1.tar (as stdin) => ais://mybucket/img-unpacked 647 ``` 648 649 ## Put directory 650 651 Put two objects, `/home/user/bck/img1.tar` and `/home/user/bck/img2.zip`, into the root of bucket `mybucket`. 652 Note that the path `/home/user/bck` is a shortcut for `/home/user/bck/*` and that recursion is disabled by default. 653 654 ```console 655 $ ais put "/home/user/bck" ais://mybucket 656 657 # PUT /home/user/bck/img1.tar => img1.tar 658 # PUT /home/user/bck/img2.tar => img2.zip 659 ``` 660 661 Alternatively, to reference source directory we can use relative (`../..`) naming. 662 663 Also notice progress bar (the `--progress` flag) and `g*` wildcard that allows to select only the filenames that start with 'g' 664 665 ```console 666 $ ais put "../../../../bin/g*" ais://vvv --progress 667 Files to upload: 668 EXTENSION COUNT SIZE 669 8 99.82MiB 670 .0 2 46.28MiB 671 TOTAL 10 146.10MiB 672 Proceed putting to ais://vvv? [Y/N]: y 673 Uploaded files progress 10/10 [==============================================================] 100 % 674 Uploaded sizes progress 146.10 MiB / 146.10 MiB [==============================================================] 100 % 675 PUT 10 objects to "ais://vvv" 676 ``` 677 678 > NOTE double quotes to denote the `"../../../../bin/g*"` source above. With pattern matching, using quotation marks is a MUST. Single quotes can be used as well. 679 680 ## Put multiple files with prefix added to destination object names 681 682 The multi-file source can be: a directory, a comma-separated list, a template-defined range - all of the above. 683 684 Examples follow below, but also notice: 685 * the flexibility in terms specifying source-matching templates, and 686 * destination prefix - with or without trailing forward slash 687 688 ### Example 1. 689 690 ```console 691 $ ais put ais://nnn/fff --template "/tmp/www/shard-{001..002}.tar" 692 Warning: 'fff' will be used as the destination name prefix for all files matching '/tmp/www/shard-{001..002}.tar' 693 Proceed anyway? [Y/N]: y 694 Files to upload: 695 EXTENSION COUNT SIZE 696 .tar 2 17.00KiB 697 TOTAL 2 17.00KiB 698 PUT 2 files => ais://nnn/fff? [Y/N]: y 699 Done 700 $ ais ls ais://nnn 701 NAME SIZE 702 fffshard-001.tar 8.50KiB 703 fffshard-002.tar 8.50KiB 704 ``` 705 706 ### Example 2. 707 708 Same as above, except now we make sure that destination is a virtual directory (notice trailing forward '/'): 709 710 ```console 711 $ ais put ais://nnn/ggg/ --template "/tmp/www/shard-{003..004}.tar" 712 Files to upload: 713 EXTENSION COUNT SIZE 714 .tar 2 17.00KiB 715 TOTAL 2 17.00KiB 716 PUT 2 files => ais://nnn/ggg/? [Y/N]: y 717 Done 718 $ ais ls ais://nnn 719 NAME SIZE 720 fffshard-001.tar 8.50KiB 721 fffshard-002.tar 8.50KiB 722 ggg/shard-003.tar 8.50KiB 723 ggg/shard-004.tar 8.50KiB 724 ``` 725 726 ### Example 3. 727 728 Same as above, with `--template` embedded into the source argument: 729 730 ```console 731 $ ais put "/tmp/www/shard-{005..006}.tar" ais://nnn/hhh/ 732 Files to upload: 733 EXTENSION COUNT SIZE 734 .tar 2 17.00KiB 735 TOTAL 2 17.00KiB 736 PUT 2 files => ais://nnn/hhh/? [Y/N]: y 737 Done 738 $ ais ls ais://nnn 739 NAME SIZE 740 fffshard-001.tar 8.50KiB 741 fffshard-002.tar 8.50KiB 742 ggg/shard-003.tar 8.50KiB 743 ggg/shard-004.tar 8.50KiB 744 hhh/shard-005.tar 8.50KiB 745 hhh/shard-006.tar 8.50KiB 746 ``` 747 748 And finally, we can certainly PUT source directory: 749 750 ### Example 4. 751 752 ```console 753 $ ais put /home/user/bck ais://mybucket/subdir/ 754 755 # PUT /home/user/bck/img1.tar => ais://mybucket/subdir/img1.tar 756 # PUT /home/user/bck/img2.tar => ais://mybucket/subdir/img2.zip 757 # PUT /home/user/bck/extra/img1.tar => ais://mybucket/subdir/extra/img1.tar 758 # PUT /home/user/bck/extra/img3.zip => ais://mybucket/subdir/extra/img3.zip 759 ``` 760 761 The same as above, but without trailing `/`. 762 763 ```console 764 $ ais put "/home/user/bck" ais://mybucket/subdir 765 766 # PUT /home/user/bck/img1.tar => ais://mybucket/subdirimg1.tar 767 # PUT /home/user/bck/img2.tar => ais://mybucket/subdirimg2.zip 768 # PUT /home/user/bck/extra/img1.tar => ais://mybucket/subdirextra/img1.tar 769 # PUT /home/user/bck/extra/img3.zip => ais://mybucket/subdirextra/img3.zip 770 ``` 771 772 ## Put multiple files into virtual directory, track progress 773 774 Same as above with source files in double quotes below, and with progress bar: 775 776 > List of sources that you want to upload can (a) comprize any number (and any mix) of comma-separated files and/or directories, and (b) must be embedded in double or single quotes. 777 778 ```console 779 $ ais put "README.md, LICENSE" ais://aaa/my-virt-dir/ --progress -y 780 Files to upload: 781 EXTENSION COUNT SIZE 782 1 1.05KiB 783 .md 1 11.24KiB 784 TOTAL 2 12.29KiB 785 Uploaded files: 2/2 [==============================================================] 100 % 786 Total size: 12.29 KiB / 12.29 KiB [==============================================================] 100 % 787 PUT 2 objects (non-recursive) to "ais://aaa" 788 ``` 789 790 > Note '/' suffix in `my-virt-dir/` above - without trailing filepath separator we would simply get a longer filename (filenames) at the root of the destination bucket. 791 792 We can now list them in the bucket `ais://aaa` the way we would list a directory: 793 794 ```console 795 $ ais ls ais://aaa --prefix my-virt-dir 796 NAME SIZE 797 my-virt-dir/LICENSE 1.05KiB 798 my-virt-dir/README.md 11.24KiB 799 ``` 800 801 ## Put pattern-matching files from directory 802 803 Same as above, except that only files matching pattern `*.tar` are PUT, so the final bucket content is `tars/img1.tar` and `tars/extra/img1.tar`. 804 805 > NOTE double quotes to denote the source. With pattern matching, using quotation marks is a MUST. Single quotes can be used as well. 806 807 ```console 808 $ ais put "~/bck/*.tar" ais://mybucket/tars/ 809 # PUT /home/user/bck/img1.tar => ais://mybucket/tars/img1.tar 810 # PUT /home/user/bck/extra/img1.tar => ais://mybucket/tars/extra/img1.tar 811 ``` 812 813 Same as above with progress bar, recursion into nested directories, and matching characters anywhere in the filename: 814 815 ```console 816 $ ais put "ais/*_t*" ais://vvv --progress --recursive 817 Files to upload: 818 EXTENSION COUNT SIZE 819 .go 43 704.40KiB 820 TOTAL 43 704.40KiB 821 PUT 43 files => ais://vvv? [Y/N]: y 822 823 Uploaded files progress 43/43 [==============================================================] 100 % 824 Uploaded sizes progress 704.40 KiB / 704.40 KiB [==============================================================] 100 % 825 PUT 43 objects to "ais://vvv" 826 ``` 827 828 The result will look as follows: 829 ```console 830 ... 831 test/target_test.go 1.55KiB 832 test/various_test.go 510B 833 test/xaction_test.go 2.61KiB 834 tgtobj_test.go 5.57KiB 835 utils_test.go 1.38KiB 836 ``` 837 838 ## Put a range of files 839 840 There are several equivalent ways to PUT a templated range of files: 841 842 ### Example 1. 843 844 Put 9 files to `mybucket` using a range request. Note the formatting of object names. 845 They exclude the longest parent directory of path which doesn't contain a template (`{a..b}`). 846 847 ```bash 848 $ for d1 in {0..2}; do for d2 in {0..2}; do echo "0" > ~/dir/test${d1}${d2}.txt; done; done 849 850 # NOTE: make sure to use double or sinle quotes around the range 851 852 $ ais put "~/dir/test{0..2}{0..2}.txt" ais://mybucket -y 853 9 objects put into "ais://mybucket" bucket 854 ``` 855 856 ### Example 2. PUT a range of files into virtial directory 857 858 Same as above but in addition destination object names will have additional prefix `subdir/` (notice the trailing `/`) 859 860 In other words, this PUT in affect creates a **virtual directory** inside destination `ais://mybucket` 861 862 ```bash 863 # prep test files 864 $ for d1 in {0..2}; do for d2 in {0..2}; do echo "0" > ~/dir/test${d1}${d2}.txt; done; done 865 866 $ ais put "~/dir/test{0..2}{0..2}.txt" ais://mybucket/subdir/ -y 867 ``` 868 869 ### Example 3. 870 Finally, the same exact operation can be accomplished using `--template` option 871 872 > `--template` is universally supported to specify a range of files or objects 873 874 ```console 875 $ ais put ais://mybucket/dir/ -y --template "~/dir/test{0..2}{0..2}.txt" 876 ``` 877 878 ## Put a list of files 879 880 There are several equivalent ways to PUT a _list_ of files: 881 882 ### Example 1. Notice the double quotes (single quotes can be used as well) 883 884 ```console 885 $ ais put "README.md,LICENSE" s3://abc 886 Files to upload: 887 EXTENSION COUNT SIZE 888 1 1.05KiB 889 .md 1 11.24KiB 890 TOTAL 2 12.29KiB 891 PUT 2 files => s3://abc? [Y/N]: y 892 ``` 893 894 ### Example 2. 895 896 Alternatively, the same can be done using the `--list` flag: 897 898 > `--list` is universally supported to specify a list of files or objects 899 900 ```console 901 $ ais put s3://abc --list "README.md,LICENSE" 902 903 Files to upload: 904 EXTENSION COUNT SIZE 905 1 1.05KiB 906 .md 1 11.24KiB 907 TOTAL 2 12.29KiB 908 PUT 2 files => s3://abc? [Y/N]: y 909 ``` 910 911 ### Example 3. PUT a list into virtual directory 912 913 The only difference from the two examples above is: **trailing `/` in the destination name**. 914 915 ```console 916 $ ais put ais://abc/subdir/ --list 'LICENSE,README.md' -y 917 918 $ ais ls ais://abc 919 NAME SIZE 920 subdir/LICENSE 1.05KiB 921 subdir/README.md 11.24KiB 922 ``` 923 924 ## Dry-Run option 925 926 Preview the files that would be sent to the cluster, without actually putting them. 927 928 ### Example 1 929 930 ```bash 931 $ for d1 in {0..2}; do for d2 in {0..2}; mkdir -p ~/dir/test${d1}/dir && do echo "0" > ~/dir/test${d1}/dir/test${d2}.txt; done; done 932 $ ais put "~/dir/test{0..2}/dir/test{0..2}.txt" ais://mybucket --dry-run 933 934 [DRY RUN] No modifications on the cluster 935 /home/user/dir/test0/dir/test0.txt => ais://mybucket/test0/dir/test0.txt 936 (...) 937 ``` 938 939 ### Example 2 940 941 Generally, the `--template` option combines (an optional) prefix and/or one or more ranges (e.g., bash brace expansions). 942 943 In this example, we only use the "prefix" part of the `--template` to specify source directory. 944 945 ```console 946 $ ls -l /tmp/w 947 total 32 948 -rw-r--r-- 1 root root 14180 Dec 11 18:18 111 949 -rw-r--r-- 1 root root 14180 Dec 11 18:18 222 950 951 $ ais put ais://nnn/fff --template /tmp/w --dry-run 952 [DRY RUN] with no modifications to the cluster 953 Warning: 'fff' will be used as the destination name prefix for all files from '/tmp/w' directory 954 Proceed anyway? [Y/N]: y 955 Files to upload: 956 EXTENSION COUNT SIZE 957 2 27.70KiB 958 TOTAL 2 27.70KiB 959 [DRY RUN] PUT 2 files (one directory, non-recursive) => ais://nnn/fff 960 PUT /tmp/w/222 -> ais://nnn/fff222 961 PUT /tmp/w/111 -> ais://nnn/fff111 962 ``` 963 964 > Note: to PUT files into a virtual destination directory, use trailing '/', e.g.: `ais put ais://nnn/fff/ ...` 965 966 ## Put multiple directories 967 968 Put multiple directories into the cluster with range syntax. 969 970 ```bash 971 $ for d1 in {0..10}; do mkdir dir$d1 && for d2 in {0..2}; do echo "0" > dir$d1/test${d2}.txt; done; done 972 $ ais put "dir{0..10}" ais://mybucket -y 973 33 objects put into "ais://mybucket" bucket 974 # PUT "/home/user/dir0/test0.txt" => b/dir0/test0.txt and 32 more 975 ``` 976 977 ## Put multiple directories with the `--skip-vc` option 978 979 > The `--skip-vc` option allows AIS to skip loading existing object's metadata to perform metadata-associated processing (such as comparing source and destination checksums, for instance). In certain scenarios (e.g., massive uploading of new files that cannot be present in the bucket) this can help reduce PUT latency. 980 981 ```bash 982 $ for d1 in {0..10}; do mkdir dir$d1 && for d2 in {0..2}; do echo "0" > dir$d1/test${d2}.txt; done; done 983 $ ais put "dir{0..10}" ais://mybucket -y --skip-vc 984 985 Files to upload: 986 EXTENSION COUNT SIZE 987 .txt 33 66B 988 TOTAL 33 66B 989 ``` 990 991 # Promote files and directories 992 993 Inline help follows below: 994 995 ```console 996 $ ais object promote --help 997 NAME: 998 ais object promote - PROMOTE target-accessible files and directories. 999 The operation is intended for copying NFS and SMB shares mounted on any/all targets 1000 but can be also used to copy local files (again, on any/all targets in the cluster). 1001 Copied files and directories become regular stored objects that can be further listed and operated upon. 1002 Destination naming is consistent with 'ais put' command, e.g.: 1003 - 'promote /tmp/subdir/f1 ais://nnn' - ais://nnn/f1 1004 - 'promote /tmp/subdir/f2 ais://nnn/aaa' - ais://nnn/aaa 1005 - 'promote /tmp/subdir/f3 ais://nnn/aaa/' - ais://nnn/aaa/f3 1006 - 'promote /tmp/subdir ais://nnn' - ais://nnn/f1, ais://nnn/f2, ais://nnn/f3 1007 - 'promote /tmp/subdir ais://nnn/aaa/' - ais://nnn/aaa/f1, ais://nnn/aaa/f2, ais://nnn/aaa/f3 1008 Other supported options follow below. 1009 1010 USAGE: 1011 ais object promote [command options] FILE|DIRECTORY[/PATTERN] BUCKET[/OBJECT_NAME_or_PREFIX] 1012 1013 OPTIONS: 1014 --recursive, -r recursive operation 1015 --overwrite-dst, -o overwrite destination, if exists 1016 --not-file-share each target must act autonomously skipping file-share auto-detection and promoting the entire source (as seen from the target) 1017 --delete-src delete successfully promoted source 1018 --target-id value ais target designated to carry out the entire operation 1019 --verbose, -v verbose output 1020 --help, -h show help 1021 ``` 1022 1023 ## Options 1024 1025 | Flag | Type | Description | Default | 1026 | --- | --- | --- | --- | 1027 | `--verbose` or `-v` | `bool` | Verbose output | `false` | 1028 | `--target-id` | `string` | Target ID; if specified, only the file/dir content stored on the corresponding AIS target is promoted | `""` | 1029 | `--recursive` or `-r` | `bool` | Promote nested directories | `false` | 1030 | `--overwrite-dst` or `-o` | `bool` | Overwrite destination (object) if exists | `false` | 1031 | `--delete-src` | `bool` | Delete promoted source | `false` | 1032 | `--not-file-share` | `bool` | Each target must act autonomously, skipping file-share auto-detection and promoting the entire source (as seen from _the_ target) | `false` | 1033 1034 ## Destination naming 1035 1036 See above. 1037 1038 ## Promote a single file 1039 1040 Promote `/tmp/examples/example1.txt` without specified object name. 1041 1042 ```console 1043 $ ais object promote /tmp/examples/example1.txt ais://mybucket --keep=true 1044 # PROMOTE /tmp/examples/example1.txt => ais://mybucket/example1.txt 1045 ``` 1046 1047 ## Promote file while specifying custom (resulting) name 1048 1049 Promote /tmp/examples/example1.txt as object with name `example1.txt`. 1050 1051 ```console 1052 $ ais object promote /tmp/examples/example1.txt ais://mybucket/example1.txt --keep=true 1053 # PROMOTE /tmp/examples/example1.txt => ais://mybucket/example1.txt 1054 ``` 1055 1056 ## Promote a directory 1057 1058 Make AIS objects out of `/tmp/examples` files (**one file = one object**). 1059 `/tmp/examples` is a directory present on some (or all) of the deployed storage nodes. 1060 1061 ```console 1062 $ ais object promote /tmp/examples ais://mybucket/ -r --keep=true 1063 ``` 1064 1065 ## Promote directory with custom prefix 1066 1067 Promote `/tmp/examples` files to AIS objects. Object names will have `examples/` prefix. 1068 1069 ```console 1070 $ ais object promote /tmp/examples ais://mybucket/examples/ -r --keep=false 1071 ``` 1072 1073 ## Promote invalid path 1074 1075 Try to promote a file that does not exist. 1076 1077 ```console 1078 $ ais create ais://testbucket 1079 "ais://testbucket" bucket created 1080 $ ais show cluster 1081 TARGET MEM USED % MEM AVAIL CAP USED % CAP AVAIL CPU USED % REBALANCE 1082 1014646t8081 0.00% 4.00GiB 59% 375.026GiB 0.00% finished 1083 ... 1084 $ ais object promote /target/1014646t8081/nonexistent/dir/ ais://testbucket --target 1014646t8081 --keep=false 1085 (...) Bad Request: stat /target/1014646t8081/nonexistent/dir: no such file or directory 1086 ``` 1087 1088 # APPEND object 1089 1090 APPEND operation (not to confuse with appending or [adding to existing archive](/docs/cli/archive.md)) can be executed in 3 different ways: 1091 1092 * using `ais put` with `--append` option; 1093 * using `ais object concat`; 1094 and finally 1095 * writing from standard input with chunk size (ie., `--chunk-size`) small enough to require (appending) multiple chunks. 1096 1097 Here're some examples: 1098 1099 ```console 1100 ## append all files from a given directory as a single object: 1101 1102 $ ais put docs ais://nnn/all-docs --append 1103 1104 Created ais://nnn/all-docs (size 571.45KiB) 1105 $ ais ls ais://nnn/all-docs -props all 1106 PROPERTY VALUE 1107 atime 11 Dec 23 12:18 EST 1108 checksum xxhash[f0eac0698e2489ff] 1109 copies 1 [/ais/mp1/7] 1110 custom - 1111 ec - 1112 location t[VQWtTyuI]:mp[/ais/mp1/7, nvme0n1] 1113 name ais://nnn/all-docs 1114 size 571.45KiB 1115 version 1 1116 ``` 1117 1118 ```console 1119 ## overwrite existing object with 4KiB of random data; 1120 ## note that the operation (below) will write about 410 chunks from standard input 1121 1122 $ head -c 4096 /dev/urandom | ais object put - ais://nnn/all-docs --chunk-size 10 1123 PUT (standard input) => ais://nnn/all-docs 1124 1125 $ ais ls ais://nnn/all-docs -props all 1126 PROPERTY VALUE 1127 atime 11 Dec 23 12:21 EST 1128 checksum xxhash[b5edf46a1b9459fb] 1129 copies 1 [/ais/mp1/7] 1130 custom - 1131 ec - 1132 location t[VQWtTyuI]:mp[/ais/mp1/7, nvme0n1] 1133 name ais://nnn/all-docs 1134 size 4.00KiB 1135 version 3 1136 ``` 1137 1138 # Delete object 1139 1140 `ais object rm BUCKET/[OBJECT_NAME]...` 1141 1142 Delete an object or list/range of objects from the bucket. 1143 1144 * For multi-object delete operation, please see: [Operations on Lists and Ranges](#operations-on-lists-and-ranges) below. 1145 1146 ## Delete a single object 1147 1148 Delete object `myobj.tgz` from bucket `mybucket`. 1149 1150 ```console 1151 $ ais object rm ais://mybucket/myobj.tgz 1152 myobj.tgz deleted from ais://mybucket bucket 1153 ``` 1154 1155 ## Delete multiple space-separated objects 1156 1157 Delete objects (`obj1`, `obj2`) from buckets (`aisbck`, `cloudbck`) respectively. 1158 1159 ```console 1160 $ ais object rm ais://aisbck/obj1.tgz aws://cloudbck/obj2.tgz 1161 obj1.tgz deleted from ais://aisbck bucket 1162 obj2.tgz deleted from aws://cloudbck bucket 1163 ``` 1164 1165 * NOTE: for each space-separated object name CLI sends a separate request. 1166 * For multi-object delete that operates on a `--list` or `--template`, please see: [Operations on Lists and Ranges](#operations-on-lists-and-ranges) below. 1167 1168 # Evict object 1169 1170 `ais bucket evict BUCKET/[OBJECT_NAME]...` 1171 1172 [Evict](/docs/bucket.md#prefetchevict-objects) object(s) from a bucket that has [remote backend](/docs/bucket.md). 1173 1174 * NOTE: for each space-separated object name CLI sends a separate request. 1175 * For multi-object eviction that operates on a `--list` or `--template`, please see: [Operations on Lists and Ranges](#operations-on-lists-and-ranges) below. 1176 1177 ## Evict a single object 1178 1179 Put `file.txt` object to `cloudbucket` bucket and evict it locally. 1180 1181 ```console 1182 $ ais put file.txt aws://cloudbucket/file.txt 1183 PUT file.txt into bucket aws://cloudbucket 1184 1185 $ ais bucket summary aws://cloudbucket --cached # show only cloudbucket objects present in the AIS cluster 1186 NAME OBJECTS SIZE USED % 1187 aws://cloudbucket 1 702B 0% 1188 1189 $ ais bucket evict aws://cloudbucket/file.txt 1190 file.txt evicted from aws://cloudbucket bucket 1191 1192 $ ais bucket summary aws://cloudbucket --cached 1193 NAME OBJECTS SIZE USED % 1194 aws://cloudbucket 0 0B 0% 1195 ``` 1196 1197 ## Evict a range of objects 1198 1199 ```console 1200 $ ais bucket evict aws://cloudbucket --template "shard-{900..999}.tar" 1201 ``` 1202 1203 # Move object 1204 1205 `ais object mv BUCKET/OBJECT_NAME NEW_OBJECT_NAME` 1206 1207 Move (rename) an object within an ais bucket. Moving objects from one bucket to another bucket is not supported. 1208 If the `NEW_OBJECT_NAME` already exists, it will be overwritten without confirmation. 1209 1210 # Concat objects 1211 1212 `ais object concat DIRNAME|FILENAME [DIRNAME|FILENAME...] BUCKET/OBJECT_NAME` 1213 1214 Create an object in a bucket by concatenating the provided files in the order of the arguments provided. 1215 If an object of the same name exists, the object will be overwritten without confirmation. 1216 1217 If a directory is provided, files within the directory are sent in lexical order of filename to the cluster for concatenation. 1218 Recursive iteration through directories and wildcards is supported in the same way as the PUT operation. 1219 1220 ## Options 1221 1222 | Flag | Type | Description | Default | 1223 | --- | --- | --- | --- | 1224 | `--recursive` or `-r` | `bool` | Enable recursive directory upload | 1225 | `--progress` | `bool` | Displays progress bar | `false` | 1226 1227 ## Concat two files 1228 1229 In two separate requests sends `file1.txt` and `dir/file2.txt` to the cluster, concatenates the files keeping the order and saves them as `obj` in bucket `mybucket`. 1230 1231 ```console 1232 $ ais object concat file1.txt dir/file2.txt ais://mybucket/obj 1233 ``` 1234 1235 ## Concat with progress bar 1236 1237 Same as above, but additionally shows progress bar of sending the files to the cluster. 1238 1239 ```console 1240 $ ais object concat file1.txt dir/file2.txt ais://mybucket/obj --progress 1241 ``` 1242 1243 ## Concat files from directories 1244 1245 Creates `obj` in bucket `mybucket` which is concatenation of sorted files from `dirB` with sorted files from `dirA`. 1246 1247 ```console 1248 $ ais object concat dirB dirA ais://mybucket/obj 1249 ``` 1250 1251 # Set custom properties 1252 1253 Generally, AIS objects have two kinds of properties: system and, optionally, custom (user-defined). Unlike the system-maintained properties, such as checksum and the number of copies (or EC parity slices, etc.), custom properties may have arbitrary user-defined names and values. 1254 1255 Custom properties are not impacted by object updates (PUTs) -- a new version of an object simply inherits custom properties of the previous version as is with no changes. 1256 1257 The command's syntax is similar to the one used to assign [bucket properties](bucket.md#set-bucket-properties): 1258 1259 `ais object set-custom [command options] BUCKET/OBJECT_NAME JSON_SPECIFICATION|KEY=VALUE [KEY=VALUE...]`, 1260 1261 for example: 1262 1263 ```console 1264 $ ais put README.md ais://abc 1265 $ ais object set-custom ais://abc/README.md mykey1=value1 mykey2=value2 1266 1267 # or, the same using JSON formatting: 1268 $ ais object set-custom ais://abc/README.md '{"mykey1":"value1", "mykey2":"value2"}' 1269 ``` 1270 1271 To show the results: 1272 1273 ```console 1274 $ ais show object ais://abc/README.md --props=all 1275 PROPERTY VALUE 1276 atime 30 Jun 21 09:43 PDT 1277 cached yes 1278 checksum 47904b6991a92ca9 1279 copies 1 1280 custom mykey1=value1, mykey2=value2 1281 ec - 1282 name ais://abc/README.md 1283 size 13.13KiB 1284 version 1 1285 ``` 1286 1287 Note the flag `--props=all` used to show _all_ object's properties including the custom ones, if available. 1288 1289 # Operations on Lists and Ranges 1290 1291 Generally, multi-object operations are supported in 2 different ways: 1292 1293 1. specifying source directory in the command line - see e.g. [Promote files and directories](#promote-files-and-directories) and [Concat objects](#concat-objects); 1294 2. via `--list` or `--template` options, whereby the latter supports Bash expansion syntax and can also contain prefix, such as a virtual parent directory, etc.) 1295 1296 This section documents and exemplifies AIS CLI operating on multiple (source) objects that you can specify either explicitly or implicitly 1297 using the `--list` or `--template` flags. 1298 1299 The number of objects "involved" in a single operation does not have any designed-in limitations: all AIS targets work on a given multi-object operation simultaneously and in parallel. 1300 1301 * **See also:** [List/Range Operations](/docs/batch.md#listrange-operations). 1302 1303 ## Prefetch objects 1304 1305 This is `ais start prefetch` or, same, `ais prefetch` command: 1306 1307 ```console 1308 $ ais prefetch --help 1309 NAME: 1310 ais prefetch - (alias for "object prefetch") prefetch one remote bucket, multiple remote buckets, or 1311 selected objects in a given remote bucket or buckets, e.g.: 1312 - 'prefetch gs://abc' - prefetch entire bucket (all gs://abc objects that are _not_ present in the cluster); 1313 - 'prefetch gs:' - prefetch all visible/accessible GCP buckets; 1314 - 'prefetch gs://abc --template images/' - prefetch all objects from the virtual subdirectory "images"; 1315 - 'prefetch gs://abc/images/' - same as above; 1316 - 'prefetch gs://abc --template "shard-{0000..9999}.tar.lz4"' - prefetch the matching range (prefix + brace expansion); 1317 - 'prefetch "gs://abc/shard-{0000..9999}.tar.lz4"' - same as above (notice double quotes) 1318 1319 USAGE: 1320 ais prefetch [command options] BUCKET[/OBJECT_NAME_or_TEMPLATE] [BUCKET[/OBJECT_NAME_or_TEMPLATE] ...] 1321 1322 OPTIONS: 1323 --list value comma-separated list of object or file names, e.g.: 1324 --list 'o1,o2,o3' 1325 --list "abc/1.tar, abc/1.cls, abc/1.jpeg" 1326 or, when listing files and/or directories: 1327 --list "/home/docs, /home/abc/1.tar, /home/abc/1.jpeg" 1328 --template value template to match object or file names; may contain prefix (that could be empty) with zero or more ranges 1329 (with optional steps and gaps), e.g.: 1330 --template "" # (an empty or '*' template matches eveything) 1331 --template 'dir/subdir/' 1332 --template 'shard-{1000..9999}.tar' 1333 --template "prefix-{0010..0013..2}-gap-{1..2}-suffix" 1334 and similarly, when specifying files and directories: 1335 --template '/home/dir/subdir/' 1336 --template "/abc/prefix-{0010..9999..2}-suffix" 1337 --wait wait for an asynchronous operation to finish (optionally, use '--timeout' to limit the waiting time) 1338 --timeout value maximum time to wait for a job to finish; if omitted: wait forever or until Ctrl-C; 1339 valid time units: ns, us (or µs), ms, s (default), m, h 1340 --progress show progress bar(s) and progress of execution in real time 1341 --refresh value interval for continuous monitoring; 1342 valid time units: ns, us (or µs), ms, s (default), m, h 1343 --dry-run preview the results without really running the action 1344 --prefix value select objects that have names starting with the specified prefix, e.g.: 1345 '--prefix a/b/c' - matches names 'a/b/c/d', 'a/b/cdef', and similar; 1346 '--prefix a/b/c/' - only matches objects from the virtual directory a/b/c/ 1347 --latest check in-cluster metadata and, possibly, GET, download, prefetch, or copy the latest object version 1348 from the associated remote bucket: 1349 - provides operation-level control over object versioning (and version synchronization) 1350 without requiring to change bucket configuration 1351 - the latter can be done using 'ais bucket props set BUCKET versioning' 1352 - see also: 'ais ls --check-versions', 'ais cp', 'ais prefetch', 'ais get' 1353 --help, -h show help 1354 ``` 1355 1356 Note usage examples above. You can always run `--help` option to see the most recently updated inline help. 1357 1358 ### See also 1359 * [Prefetch/Evict objects](/docs/bucket.md#prefetchevict-objects) 1360 1361 ### Example: prefetch using prefix 1362 1363 Initially: 1364 1365 ```console 1366 $ ais ls s3://abc --all --limit 10 1367 NAME SIZE CACHED STATUS 1368 10000a2 10.00MiB no n/a 1369 10000b4 10.00MiB no n/a 1370 10000bd 10.00MiB no n/a 1371 10000d6 10.00MiB no n/a 1372 10000ea 10.00MiB no n/a 1373 10001a2 10.00MiB no n/a 1374 10001b4 10.00MiB no n/a 1375 10001bd 10.00MiB no n/a 1376 10001d6 10.00MiB no n/a 1377 10001ea 10.00MiB no n/a 1378 ``` 1379 1380 Now, let's use `--prefix` option to - in this case - fetch a single object: 1381 1382 ```console 1383 $ ais prefetch s3://abc --prefix 10000a2 1384 prefetch-objects[E0e5mq9Kav]: prefetch "10000a2" from s3://abc. To monitor the progress, run 'ais show job E0e5mq9Kav' 1385 1386 $ ais ls s3://abc --all --limit 10 1387 NAME SIZE CACHED STATUS 1388 10000a2 10.00MiB yes ok ### <<<<< in cluster 1389 10000b4 10.00MiB no n/a 1390 10000bd 10.00MiB no n/a 1391 10000d6 10.00MiB no n/a 1392 10000ea 10.00MiB no n/a 1393 10001a2 10.00MiB no n/a 1394 10001b4 10.00MiB no n/a 1395 10001bd 10.00MiB no n/a 1396 10001d6 10.00MiB no n/a 1397 10001ea 10.00MiB no n/a 1398 ``` 1399 1400 ### Example: prefetch using template 1401 1402 Since `--template` can optionally contain prefix and zero or more _ranges_, we could execute the above example as follows: 1403 1404 ```console 1405 $ ais prefetch s3://abc --template 10000a2 1406 ``` 1407 1408 This, in fact, would produce the same result (see previous section). 1409 1410 But of course, "templated" match can also specify an actual range, for example: 1411 1412 ```console 1413 $ ais ls gs://nnn --all --limit 5 1414 NAME SIZE CACHED STATUS 1415 shard-001 1.00MiB no n/a 1416 shard-002 1.00MiB no n/a 1417 shard-003 1.00MiB no n/a 1418 shard-004 1.00MiB no n/a 1419 shard-005 1.00MiB no n/a 1420 1421 $ ais prefetch gs://nnn --template --template "shard-{001..003}" 1422 1423 $ ais ls gs://nnn --all --limit 5 1424 NAME SIZE CACHED STATUS 1425 shard-001 1.00MiB yes ok 1426 shard-002 1.00MiB yes ok 1427 shard-003 1.00MiB yes ok 1428 shard-004 1.00MiB no n/a 1429 shard-005 1.00MiB no n/a 1430 ``` 1431 1432 ### Example: prefetch a list of objects 1433 1434 NOTE: make sure to use double or single quotations to specify the list, as shown below. 1435 1436 ```console 1437 # Prefetch o1, o2, and o3 from AWS bucket `cloudbucket`: 1438 $ ais prefetch aws://cloudbucket --list 'o1,o2,o3' 1439 ``` 1440 1441 ### Example: prefetch a range of objects 1442 1443 ```console 1444 # Prefetch from AWS bucket `cloudbucket` all objects in the specified range. 1445 # NOTE: make sure to use double or single quotations to specify the template (aka "range") 1446 1447 $ ais prefetch aws://cloudbucket --template "shard-{001..999}.tar" 1448 ``` 1449 1450 ## Delete multiple objects 1451 1452 `ais object rm BUCKET/[OBJECT_NAME]...` 1453 1454 Delete an object or list or range of objects from a bucket. 1455 1456 ### Options 1457 1458 | Flag | Type | Description | Default | 1459 | --- | --- | --- | --- | 1460 | `--list` | `string` | Comma separated list of objects for list deletion | `""` | 1461 | `--template` | `string` | The object name template with optional range parts | `""` | 1462 1463 ### Delete a list of objects 1464 1465 Delete a list of objects (`obj1`, `obj2`, `obj3`) from bucket `mybucket`. 1466 1467 NOTE: when specifying a comma-delimited `--list` option, make sure to use double or single quotations as shown below. 1468 1469 ```console 1470 $ ais object rm ais://mybucket --list "obj1, obj2, obj3" 1471 [obj1 obj2] removed from ais://mybucket bucket 1472 ``` 1473 1474 ### Delete a range of objects 1475 1476 ```console 1477 # Delete from bucket `mybucket` all objects in the range `001-003` with prefix `test-`. 1478 # NOTE: when specifying template (aka "range") make sure to use double or single quotation marks. 1479 1480 $ ais object rm ais://mybucket --template "test-{001..003}" 1481 removed files in the range 'test-{001..003}' from ais://mybucket bucket 1482 ``` 1483 1484 And one other example (that also includes generating .tar shards): 1485 1486 ```console 1487 $ ais archive gen-shards "ais://dsort-testing/shard-{001..999}.tar" --fcount 256 1488 Shards created: 999/999 [==============================================================] 100 % 1489 1490 # NOTE: make sure to use double or single quotations to specify the template (aka "range") 1491 $ ais object rm ais://dsort-testing --template 'shard-{900..999}.tar' 1492 removed from ais://dsort-testing objects in the range "shard-{900..999}.tar", use 'ais job show xaction EH291ljOy' to monitor the progress 1493 ``` 1494 1495 ## Evict multiple objects 1496 1497 `ais evict [command options] BUCKET[/OBJECT_NAME_or_TEMPLATE] [BUCKET[/OBJECT_NAME_or_TEMPLATE] ...]` 1498 1499 Command `ais evict` is a shorter version of `ais bucket evict`. 1500 1501 ### Options 1502 1503 Here's inline help, and specifically notice the _multi-object_ options: `--template`, `--list`, and `--prefix`: 1504 1505 ```concole 1506 $ ais evict --help 1507 NAME: 1508 ais evict - (alias for "bucket evict") evict one remote bucket, multiple remote buckets, or 1509 selected objects in a given remote bucket or buckets, e.g.: 1510 - 'evict gs://abc' - evict entire bucket (all gs://abc objects in aistore); 1511 - 'evict gs:' - evict all GCP buckets from the cluster; 1512 - 'evict gs://abc --template images/' - evict all objects from the virtual subdirectory "images"; 1513 - 'evict gs://abc/images/' - same as above; 1514 - 'evict gs://abc --template "shard-{0000..9999}.tar.lz4"' - evict the matching range (prefix + brace expansion); 1515 - 'evict "gs://abc/shard-{0000..9999}.tar.lz4"' - same as above (notice double quotes) 1516 1517 USAGE: 1518 ais evict [command options] BUCKET[/OBJECT_NAME_or_TEMPLATE] [BUCKET[/OBJECT_NAME_or_TEMPLATE] ...] 1519 1520 OPTIONS: 1521 --list value comma-separated list of object or file names, e.g.: 1522 --list 'o1,o2,o3' 1523 --list "abc/1.tar, abc/1.cls, abc/1.jpeg" 1524 or, when listing files and/or directories: 1525 --list "/home/docs, /home/abc/1.tar, /home/abc/1.jpeg" 1526 --template value template to match object or file names; may contain prefix (that could be empty) with zero or more ranges 1527 (with optional steps and gaps), e.g.: 1528 --template "" # (an empty or '*' template matches eveything) 1529 --template 'dir/subdir/' 1530 --template 'shard-{1000..9999}.tar' 1531 --template "prefix-{0010..0013..2}-gap-{1..2}-suffix" 1532 and similarly, when specifying files and directories: 1533 --template '/home/dir/subdir/' 1534 --template "/abc/prefix-{0010..9999..2}-suffix" 1535 --wait wait for an asynchronous operation to finish (optionally, use '--timeout' to limit the waiting time) 1536 --timeout value maximum time to wait for a job to finish; if omitted: wait forever or until Ctrl-C; 1537 valid time units: ns, us (or µs), ms, s (default), m, h 1538 --progress show progress bar(s) and progress of execution in real time 1539 --refresh value interval for continuous monitoring; 1540 valid time units: ns, us (or µs), ms, s (default), m, h 1541 --keep-md keep bucket metadata 1542 --prefix value select objects that have names starting with the specified prefix, e.g.: 1543 '--prefix a/b/c' - matches names 'a/b/c/d', 'a/b/cdef', and similar; 1544 '--prefix a/b/c/' - only matches objects from the virtual directory a/b/c/ 1545 --dry-run preview the results without really running the action 1546 --verbose, -v verbose output 1547 --non-verbose, --nv non-verbose (quiet) output, minimized reporting 1548 --help, -h show help 1549 ``` 1550 1551 Note usage examples above. You can always run `--help` option to see the most recently updated inline help. 1552 1553 ### Evict a range of objects 1554 1555 ```console 1556 $ ais bucket evict aws://cloudbucket --template "shard-{900..999}.tar" 1557 ```