|
| 1 | +--- |
| 2 | +title: Service Independent CLI |
| 3 | +date: 2025-11-13T00:00:00+00:00 |
| 4 | +geekdocRepo: https://github.com/owncloud/ocis |
| 5 | +geekdocEditPath: edit/master/docs/cli-commands/ |
| 6 | +geekdocFilePath: service_independent_cli.md |
| 7 | +--- |
| 8 | + |
| 9 | +This document describes ocis CLI commands that are **service independent**. |
| 10 | + |
| 11 | +{{< toc >}} |
| 12 | + |
| 13 | +For **service dependent** CLI commands, see the following services: |
| 14 | + |
| 15 | +* [Auth-App]({{< ref "../services/auth-app/" >}}) |
| 16 | +* [Graph]({{< ref "../services/graph/" >}}) |
| 17 | +* [Postprocessing]({{< ref "../services/postprocessing/" >}}) |
| 18 | +* [Storage-Users]({{< ref "../services/storage-users/" >}}) |
| 19 | + |
| 20 | +## Common Parameters |
| 21 | + |
| 22 | +The ocis package offers a variety of CLI commands for monitoring or repairing ocis installations. Most of these commands have common parameters such as: |
| 23 | + |
| 24 | +* `--help` (or `-h`)\ |
| 25 | + Use to print all available options. |
| 26 | + |
| 27 | +* `--basePath` (or `-p`)\ |
| 28 | + Needs to point to a storage provider, paths can vary depending on your ocis installation. Example paths are: |
| 29 | + ```bash |
| 30 | + .ocis/storage/users # bare metal installation |
| 31 | + /var/tmp/ocis/storage/users # docker installation |
| 32 | + ... |
| 33 | + ``` |
| 34 | + |
| 35 | +* `--dry-run`\ |
| 36 | + This parameter, when available, defaults to `true` and must explicitly set to `false`. |
| 37 | + |
| 38 | +* `--verbose` (or `-v`)\ |
| 39 | + Get a more verbose output. |
| 40 | + |
| 41 | +## List of CLI Commands |
| 42 | + |
| 43 | +### Backup CLI |
| 44 | + |
| 45 | +The backup command allows inspecting the consistency of an ocis storage: |
| 46 | + |
| 47 | +```bash |
| 48 | +ocis backup consistency -p /base/path/storage/users |
| 49 | +``` |
| 50 | + |
| 51 | +This will check the consistency of the storage and output a list of inconsistencies. Inconsistencies can be: |
| 52 | + |
| 53 | +* **Orphaned Blobs**\ |
| 54 | +A blob in the blobstore that is not referenced by any file metadata. |
| 55 | +* **Missing Blobs**\ |
| 56 | +A blob referenced by file metadata that is not present in the blobstore. |
| 57 | +* **Missing Nodes**\ |
| 58 | +A node that is referenced by a symlink but doesn't exist. |
| 59 | +* **Missing Link**\ |
| 60 | +A node that is not referenced by any symlink but should be. |
| 61 | +* **Missing Files**\ |
| 62 | +A node that is missing essential files (such as the `.mpk` metadata file). |
| 63 | +* **Missing/Malformed Metadata**\ |
| 64 | +A node that doesn't have any (or malformed) metadata. |
| 65 | + |
| 66 | +This command provides additional options: |
| 67 | + |
| 68 | +* `-b` / `--blobstore`\ |
| 69 | +Allows specifying the blobstore to use. Defaults to `ocis`. Empty blobs will not be checked. Can also be switched to `s3ng`, but needs addtional envvar configuration (see the `storage-users` service for more details). |
| 70 | +* `--fail`\ |
| 71 | +Exits with non-zero exit code if inconsistencies are found. Useful for automation. |
| 72 | + |
| 73 | +### Cleanup Orphaned Shares |
| 74 | + |
| 75 | +When a shared space or directory got deleted, use the `shares cleanup` command to remove those share orphans. This can't be done automatically at the moment. |
| 76 | + |
| 77 | +```bash |
| 78 | +ocis shares cleanup |
| 79 | +``` |
| 80 | + |
| 81 | +### List Unified Roles |
| 82 | + |
| 83 | +This command simplifies the process of finding out which UID belongs to which role. The command using markdown as output format is: |
| 84 | + |
| 85 | +```bash |
| 86 | +ocis graph list-unified-roles --output-format md |
| 87 | +``` |
| 88 | + |
| 89 | +The output of this command includes the following information for each role: |
| 90 | + |
| 91 | +* `Name`\ |
| 92 | + The human readable name of the role. |
| 93 | +* `UID`\ |
| 94 | + The unique identifier of the role. |
| 95 | +* `Enabled`\ |
| 96 | + Whether the role is enabled or not. |
| 97 | +* `Description`\ |
| 98 | + A short description of the role. |
| 99 | +* `Condition` |
| 100 | +* `Allowed Resource Actions` |
| 101 | + |
| 102 | +**Example output (shortned)** |
| 103 | + |
| 104 | +| # | LABEL | UID | ENABLED | DESCRIPTION | CONDITION | ALLOWED RESOURCE ACTIONS | |
| 105 | +|:--:|:--------------------------------:|:------------------------------------:|:--------:|:------------------------------------------------------------------------------------:|:---------------------------------------------------------:|:----------------------------------------:| |
| 106 | +| 1 | Viewer | b1e2218d-eef8-4d4c-b82d-0f1a1b48f3b5 | enabled | View and download. | exists @Resource.File | libre.graph/driveItem/path/read | |
| 107 | +| | | | | | exists @Resource.Folder | libre.graph/driveItem/quota/read | |
| 108 | +| | | | | | exists @Resource.File && @Subject.UserType=="Federated" | libre.graph/driveItem/content/read | |
| 109 | +| | | | | | exists @Resource.Folder && @Subject.UserType=="Federated" | libre.graph/driveItem/children/read | |
| 110 | +| | | | | | | libre.graph/driveItem/deleted/read | |
| 111 | +| | | | | | | libre.graph/driveItem/basic/read | |
| 112 | +| 2 | ViewerListGrants | d5041006-ebb3-4b4a-b6a4-7c180ecfb17d | disabled | View, download and show all invite |
| 113 | + |
| 114 | +<!-- |
| 115 | +### Move Stuck Uploads |
| 116 | +
|
| 117 | +In some cases of saturated disk usage, Infinite Scale metadata may become stuck. This can occur when file metadata is being moved to its final destination after file operations. This issue was primarily seen with shares, where uploaded files could not be accessed. The required filename parameter aligns with Infinite Scale's internal processes and is used to complete the formerly stuck move action. |
| 118 | +
|
| 119 | +```bash |
| 120 | +ocis shares move-stuck-upload-blobs [--dry-run=false] -p /base/path/storage/users |
| 121 | +``` |
| 122 | +
|
| 123 | +This command provides additional options: |
| 124 | +
|
| 125 | +* `--dry-run` (default: `true`)\ |
| 126 | +Only print found files stuck in transition.\ |
| 127 | +Note: This is a safety measure. You must specify `--dry-run=false` for the command to be effective. |
| 128 | +
|
| 129 | +* `--filename` value (default: "received.json")\ |
| 130 | +File to move from `uploads/` to share manager metadata `blobs/` |
| 131 | +--> |
| 132 | + |
| 133 | +### Revisions CLI |
| 134 | + |
| 135 | +The revisions command allows removing the revisions of files in the storage. |
| 136 | + |
| 137 | +```bash |
| 138 | +ocis revisions purge -p /base/path/storage/users |
| 139 | +``` |
| 140 | + |
| 141 | +It takes the `--resource-id` (or `--r`) parameter which specify the scope of the command: |
| 142 | + |
| 143 | +* An empty string (default) removes all revisions from all spaces. |
| 144 | +* A spaceID (like `d419032c-65b9-4f4e-b1e4-0c69a946181d\$44b5a63b-540c-4002-a674-0e9c833bbe49`) removes all revisions in that space. |
| 145 | +* A resourceID (e.g. `d419032c-65b9-4f4e-b1e4-0c69a946181d\$44b5a63b-540c-4002-a674-0e9c833bbe49\!e8a73d49-2e00-4322-9f34-9d7f178577b2`) removes all revisions from that specific file. |
| 146 | + |
| 147 | +This command provides additional options: |
| 148 | + |
| 149 | +* `--dry-run` (default: `true`)\ |
| 150 | +Do not remove any revisions but print the revisions that would be removed. |
| 151 | +* `-b` / `--blobstore`\ |
| 152 | +Allows specifying the blobstore to use. Defaults to `ocis`. Can be switched to `s3ng` but needs addtional envvar configuration (see the `storage-users` service for more details). |
| 153 | +* `-v` / `--verbose`\ |
| 154 | +Prints additional information about the revisions that are removed. |
| 155 | +* `--glob-mechanism` (default: `glob`\ |
| 156 | +(advanced) Allows specifying the mechanism to use for globbing. Can be `glob`, `list` or `workers`. In most cases the default `glob` does not need to be changed. If large spaces need to be purged, `list` or `workers` can be used to improve performance at the cost of higher cpu and ram usage. `list` will spawn 10 threads that list folder contents in parallel. `workers` will use a special globbing mechanism and multiple threads to achieve the best performance for the highest cost. |
| 157 | + |
| 158 | +### Service Health |
| 159 | + |
| 160 | +The service health CLI command allows checking the health status of a service. If there are no issues found, nothing health related will get printed. |
| 161 | + |
| 162 | +```bash |
| 163 | +ocis <service-name> health |
| 164 | +``` |
| 165 | + |
| 166 | +**Examples** |
| 167 | + |
| 168 | +* The `collaboration` service has been started but not configured and is therefore not in a healthy state: |
| 169 | + ```bash |
| 170 | + ocis collaboration health |
| 171 | + |
| 172 | + The WOPI secret has not been set properly in your config for collaboration. Make sure your /root/.ocis/config config contains the proper values (e.g. by using 'ocis init --diff' and applying the patch or setting a value manually in the config/corresponding environment variable). |
| 173 | + ``` |
| 174 | +
|
| 175 | +* The `antivirus` service has not been started, the health check responds accordingly: |
| 176 | + ```bash |
| 177 | + ocis antivirus health |
| 178 | + |
| 179 | + {"level":"fatal","service":"antivirus","error":"Get \"http://127.0.0.1:9277/healthz\": dial tcp 127.0.0.1:9277: connect: connection refused","time":"2024-10-28T17:47:54+01:00","message":"Failed to request health check"} |
| 180 | + ``` |
| 181 | +
|
| 182 | +### Trash CLI |
| 183 | +
|
| 184 | +The trash cli allows removing empty folders from the trashbin. This should be used to speed up trash bin operations. |
| 185 | +
|
| 186 | +```bash |
| 187 | +ocis trash purge-empty-dirs -p /base/path/storage/users |
| 188 | +``` |
| 189 | +
|
| 190 | +This command provides additional options: |
| 191 | +
|
| 192 | +* `--dry-run` (default: `true`)\ |
| 193 | +Do not remove any empty folders but print the empty folders that would be removed. |
0 commit comments