mongocli atlas cluster onlinearchive create
Note
Beta
Online archive is available as a Beta feature. The feature and the corresponding documentation may change at any time during the Beta stage.
The onlinearchive create
command creates an online archive for the specified collection in the M10
or higher cluster. You can also create an online archive through the
Atlas UI or API.
Syntax
mongocli atlas cluster onlinearchive create --archiveAfter <number-of-days> --clusterName <cluster-name> --collection <collection-name> --dateField <date-field-name> --db <database-name> [ --output|-o <output-format> ] --partition <partition-field-names> [ --profile|-P <profile-name> ] [ --projectId <project-ID> ]
Options
Option | Type | Description | Required? |
---|---|---|---|
--archiveAfter | int | Number of days after which to archive cluster data. | yes |
--clusterName | string | Name of the cluster. | yes |
--collection | string | Name of the collection for which to create an online archive. | yes |
--dateField | string | Name of an already indexed date field from the documents. | yes |
--db | string | Name of the database that contains the collection. | yes |
--output , -o | string | Command output format. Valid values are:
If omitted, the command returns output in the default format. | no |
partition | string | Name of the fields to use to partition data. You can specify up to two
frequently queried fields, separated by a comma, in the following format:
The data type must match the data type of the field in the documents. | no |
--profile , -P | string | Name of the profile where the public and private
keys for the project are saved. If omitted, uses the
default profile. To learn more about creating a
profile, see Configure the MongoDB CLI. | no |
--projectId | string | Unique identifier of the project. If omitted, uses the project ID in the profile or environment variable. | no |
Output
The command prints the following fields in the specified format to the terminal if the command succeeds. If the command prints an error, see Troubleshooting for recommended solutions.
Field | Type | Description |
---|---|---|
clusterName | string | Name of the cluster that contains the collection. |
collName | string | Name of the collection. |
criteria | document | Criteria to use for archiving data. |
criteria.dateField | string | Name of the date field that the online archive is based on. Data is
archived when the current date is greater than the value of the date
field plus the number of days specified via the archiveAfter option. |
criteria.expireAfterDays | int | Number of days after which to archive data as specified using the
archiveAfter option. Data is archived when the current date is
greater than the value of the date field specified via the dateField
option plus the number of days specified here. |
dbName | string | Name of the database that contains the collection. |
groupId | string | Unique identifier of the project that contains the cluster. |
partitionFields | array of documents | Fields to use to partition data. |
partitionFields.fieldName | string | Name of the field. |
partitionFields.fieldType | string | Data type of the field. |
partitionFields.order | int | Position of the field in the partition. Value can be:
|
paused | boolean | Whether or not the online archive is paused. Value is:
|
state | string | State of the online archive. Value can be:
|
Examples
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.
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.
mongocli atlas cluster onlineArchive create --clusterName myTestCluster --db sample_mflix --collection movies --dateField released --archiveAfter 2 --output json
The previous command prints the following fields in the specified format to the terminal. To learn more about these fields, see Output.
{ "_id": "5f1726ca460fd352106557c2", "clusterName": "myTestCluster", "collName": "movies", "criteria": { "dateField": "released", "expireAfterDays": 2 }, "dbName": "sample_mflix", "groupId": "5e2211c17a3e5a48f5497de3", "paused": false, "state": "PENDING" }
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
date is greater than the value of the dateField
option plus the
number of days specified through the archiveAfter
option.
mongocli atlas cluster onlineArchive create --clusterName myTestCluster --db sample_mflix --collection movies --dateField released --archiveAfter 2 --partition title:string,year:int --output json -P egAtlasProfile
The previous command prints the following fields in the specified format to the terminal. To learn more about these fields, see Output.
{ "_id": "5f173012a22aa23d58a8b2f0", "clusterName": "myTestCluster", "collName": "movies", "criteria": { "dateField": "released", "expireAfterDays": 2 }, "dbName": "sample_mflix", "groupId": "5e2211c17a3e5a48f5497de3", "partitionFields": [ { "fieldName": "title", "fieldType": "string", "order": 0 }, { "fieldName": "year", "fieldType": "number", "order": 1 }, { "fieldName": "released", "fieldType": "date", "order": 2 } ], "paused": false, "state": "PENDING" }