|
| 1 | +.. _mcli-atlas-onlinearchive-create-command: |
| 2 | + |
| 3 | +=================================== |
| 4 | +mongocli atlas onlinearchive create |
| 5 | +=================================== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +.. include:: /includes/fact-online-archive-beta.rst |
| 16 | + |
| 17 | +The ``onlinearchive create`` command creates an :atlas:`online archive |
| 18 | +</online-archive/manage-online-archive/>` for the specified collection in the ``M10`` or higher cluster. You can also create an online archive through the |
| 19 | +|service| :atlas:`UI </online-archive/configure-online-archive/>` or :atlas:`API </reference/api/online-archive-create-one/>`. |
| 20 | + |
| 21 | +.. _mcli-atlas-online-archive-create-syntax: |
| 22 | + |
| 23 | +Syntax |
| 24 | +------ |
| 25 | + |
| 26 | +.. code-block:: text |
| 27 | + |
| 28 | + mongocli atlas onlinearchive create |
| 29 | + --archiveAfter <number-of-days> |
| 30 | + --clusterName <cluster-name> |
| 31 | + --collection <collection-name> |
| 32 | + --dateField <date-field-name> |
| 33 | + --db <database-name> |
| 34 | + --partition <partition-field-names> |
| 35 | + [ --profile|-P <profile-name> ] |
| 36 | + [ --projectId <project-ID> ] |
| 37 | + |
| 38 | +.. _mcli-atlas-onlinearchive-create-options: |
| 39 | + |
| 40 | +Options |
| 41 | +------- |
| 42 | + |
| 43 | +.. list-table:: |
| 44 | + :header-rows: 1 |
| 45 | + :widths: 20 10 60 10 |
| 46 | + |
| 47 | + * - Option |
| 48 | + - Type |
| 49 | + - Description |
| 50 | + - Required? |
| 51 | + |
| 52 | + * - ``archiveAfter`` |
| 53 | + - int |
| 54 | + - Number of days after which to archive cluster data. |
| 55 | + - yes |
| 56 | + |
| 57 | + * - ``clusterName`` |
| 58 | + - string |
| 59 | + - Name of the cluster. |
| 60 | + - yes |
| 61 | + |
| 62 | + * - ``collection`` |
| 63 | + - string |
| 64 | + - Name of the collection for which to create an online archive. |
| 65 | + - yes |
| 66 | + |
| 67 | + * - ``dateField`` |
| 68 | + - string |
| 69 | + - Name of an already indexed date field from the documents. |
| 70 | + - yes |
| 71 | + |
| 72 | + * - ``db`` |
| 73 | + - string |
| 74 | + - Name of the database that contains the collection. |
| 75 | + - yes |
| 76 | + |
| 77 | + * - ``partition`` |
| 78 | + - string |
| 79 | + - Name of the fields to use to partition data. You can specify up to two |
| 80 | + frequently queried fields, separated by a comma, in the following format: ``<field-name>:<data-type>``. The order in which the fields are specified defines the position of the field in the partition. That is: |
| 81 | + |
| 82 | + - The first field has the first position (``0``) in the partition. |
| 83 | + - The second field has the second position (``1``) in the partition. |
| 84 | + |
| 85 | + The data type must match the data type of the field in the documents. |
| 86 | + - no |
| 87 | + |
| 88 | + * - ``--profile``, ``-P`` |
| 89 | + - string |
| 90 | + - Name of the profile where the public and private |
| 91 | + keys for the project are saved. If omitted, uses the |
| 92 | + {+default-profile+}. To learn more about creating a |
| 93 | + profile, see :ref:`mcli-configure`. |
| 94 | + - no |
| 95 | + |
| 96 | + * - ``--projectId`` |
| 97 | + - string |
| 98 | + - Unique identifier of the project that contains the |
| 99 | + cluster. If omitted, uses the project ID in the profile or |
| 100 | + :ref:`environment variable <mcli-env-var>`. |
| 101 | + - no |
| 102 | + |
| 103 | +.. _mcli-atlas-onlinearchive-create-output: |
| 104 | + |
| 105 | +Output |
| 106 | +------ |
| 107 | + |
| 108 | +.. include:: /includes/command-output-intro.rst |
| 109 | + |
| 110 | +.. include:: /includes/atlas-online-archive-output.rst |
| 111 | + |
| 112 | +.. _mcli-atlas-onlinearchive-create-egs: |
| 113 | + |
| 114 | +Examples |
| 115 | +-------- |
| 116 | + |
| 117 | +The following examples show two ways to create an online archive using the ``mongocli atlas onlinearchive create`` command. The **Basic Example** shows how to create an online archive without additional partition fields and the **Partitions Example** shows how to create an online archive with partitions. |
| 118 | + |
| 119 | +.. tabs:: |
| 120 | + |
| 121 | + .. tab:: Basic Example |
| 122 | + :tabid: basic |
| 123 | + |
| 124 | + The following ``mongocli atlas onlinearchive create`` command creates an online archive for the ``sample_mflix.movies`` collection in a cluster named ``myTestCluster`` using the default profile. The criteria for archiving data indicates that data should be archived when the current date is greater than the value of the ``dateField`` option plus the number of days specified through the ``archiveAfter`` option. |
| 125 | + |
| 126 | + .. code-block:: shell |
| 127 | + |
| 128 | + mongocli atlas cluster onlineArchive create --clusterName myTestCluster --db sample_mflix --collection movies --dateField released --archiveAfter 2 |
| 129 | + |
| 130 | + The previous command prints the following fields in |json| format to the |
| 131 | + terminal. To learn more about these fields, see |
| 132 | + :ref:`mcli-atlas-onlinearchive-create-output`. |
| 133 | + |
| 134 | + .. code-block:: sh |
| 135 | + :copyable: false |
| 136 | + |
| 137 | + { |
| 138 | + "_id": "5f1726ca460fd352106557c2", |
| 139 | + "clusterName": "myTestCluster", |
| 140 | + "collName": "movies", |
| 141 | + "criteria": { |
| 142 | + "dateField": "released", |
| 143 | + "expireAfterDays": 2 |
| 144 | + }, |
| 145 | + "dbName": "sample_mflix", |
| 146 | + "groupId": "5e2211c17a3e5a48f5497de3", |
| 147 | + "paused": false, |
| 148 | + "state": "PENDING" |
| 149 | + } |
| 150 | + |
| 151 | + .. tab:: Partitions Example |
| 152 | + :tabid: partitions |
| 153 | + |
| 154 | + The following ``mongocli atlas onlinearchive create`` command creates an online archive for the ``sample_mflix.movies`` collection in a cluster named ``myTestCluster`` using a profile named ``egAtlasProfile``. Data is partitioned based on the ``title`` field, ``year`` field, and ``released`` field from the documents in the collection. The criteria for archiving data indicates that data should be archived when the current |
| 155 | + date is greater than the value of the ``dateField`` option plus the |
| 156 | + number of days specified through the ``archiveAfter`` option. |
| 157 | + |
| 158 | + .. code-block:: shell |
| 159 | + |
| 160 | + mongocli atlas cluster onlineArchive create --clusterName myTestCluster --db sample_mflix --collection movies --dateField released --archiveAfter 2 --partition title:string,year:int -P egAtlasProfile |
| 161 | + |
| 162 | + The previous command prints the following fields in |json| format to the |
| 163 | + terminal. To learn more about these fields, see |
| 164 | + :ref:`mcli-atlas-onlinearchive-create-output`. |
| 165 | + |
| 166 | + .. code-block:: sh |
| 167 | + :copyable: false |
| 168 | + |
| 169 | + { |
| 170 | + "_id": "5f173012a22aa23d58a8b2f0", |
| 171 | + "clusterName": "myTestCluster", |
| 172 | + "collName": "movies", |
| 173 | + "criteria": { |
| 174 | + "dateField": "released", |
| 175 | + "expireAfterDays": 2 |
| 176 | + }, |
| 177 | + "dbName": "sample_mflix", |
| 178 | + "groupId": "5e2211c17a3e5a48f5497de3", |
| 179 | + "partitionFields": [ |
| 180 | + { |
| 181 | + "fieldName": "title", |
| 182 | + "fieldType": "string", |
| 183 | + "order": 0 |
| 184 | + }, |
| 185 | + { |
| 186 | + "fieldName": "year", |
| 187 | + "fieldType": "number", |
| 188 | + "order": 1 |
| 189 | + }, |
| 190 | + { |
| 191 | + "fieldName": "released", |
| 192 | + "fieldType": "date", |
| 193 | + "order": 2 |
| 194 | + } |
| 195 | + ], |
| 196 | + "paused": false, |
| 197 | + "state": "PENDING" |
| 198 | + } |
0 commit comments