--- title: Manage organization snapshots slug: mape0408 canonical_url: https://docs.coveo.com/en/mape0408/ collection: cli source_format: adoc --- # Manage organization snapshots The Coveo CLI can greatly facilitate [resource snapshot management](https://docs.coveo.com/en/3239/). While you could accomplish the same operations through the [Administration Console](https://docs.coveo.com/en/183/) or the [Migration API](https://platform.cloud.coveo.com/docs?urls.primaryName=Migration#/), the CLI reduces manual intervention as much as possible, simplifying your deployments with modern infrastructure-as-code. This article explains how to use the CLI to pull and push snapshots. You can use it to manage snapshots in a single [Coveo organization](https://docs.coveo.com/en/185/) or in multiple ones. ![Single vs multi org management](https://docs.coveo.com/en/assets/images/cli/cli-org-management.svg) ## Prerequisites * The Coveo CLI [installed](https://docs.coveo.com/en/cli#installation) on your machine. * One or more organizations in which you have the [privileges](https://docs.coveo.com/en/3357/) to push/pull snapshots. ## Pull an organization snapshot This section explains how to use the CLI to import a project constituting a snapshot of a target organization. Concretely, the project contains two folders: * `.coveo/`: the project metadata. * `resources/`: all the [resources](https://docs.coveo.com/en/2820/) pulled from the organization. ### Pull all resources To pull all resources available in your organization, use the [`coveo org:resources:pull`](https://docs.coveo.com/en/cli#coveo-orgresourcespull) command. ```bash coveo org:resources:pull ``` ### Pull specific resources types If you only want to pull specific types of resources, for example because you have limited access or no interest in other resources, use the `--resourceTypes` flag. In addition to pulling the target resources, it also pulls all other resources that depend on them. For example, pulling a [query pipeline](https://docs.coveo.com/en/180/) would also retrieve the rules of this pipeline and the [machine learning (ML)](https://docs.coveo.com/en/188/) [models](https://docs.coveo.com/en/1012/) associated with it. To give another example, the following command pulls all the [fields](https://docs.coveo.com/en/200/) and all the [sources](https://docs.coveo.com/en/246/) available in your organization, along with the dependent resources, but nothing else. ```bash coveo org:resources:pull --resourceTypes SOURCE FIELD ``` ### Pull resources using a snapshot model You can also provide a snapshot model to specify individual resources to pull from the organization. The snapshot model is a JSON file containing the target resource IDs. Using a snapshot model can be useful when multiple teams are working on the same organization and you would like to pull only the resources you're working on. It can also be helpful to automate tasks on a subset of resources in a CI/CD environment. ```bash coveo org:resources:pull --model path/to/model.json ``` To create a snapshot model, run the following command. ```bash coveo org:resources:model:create ``` This redirects you to the Administration Console. From there, select the specific resources to include in your snapshot model and click **Save for CLI**. The following JSON model only pulls the `myorgid-catalog` and `myorgid-inventory` sources regardless of the other sources in the organization. ```json { "orgId": "myorgid", "resourcesToExport": { "SOURCE": [ "myorgid-catalog", "myorgid-inventory" ] }, "developerNotes": "Commerce Snapshot", "includeChildrenResources": true } ``` ### Output If the `org:resources:pull` command is successful, the terminal displays the ID of the organization from which you just pulled resources as well as a confirmation that a project in the current directory was updated: ```bash Creating Snapshot from myorgid... ✔ Updating project with Snapshot... ✔ ``` You will see two folders in your working directory: * `.coveo/`: contains the project metadata. * `resources/`: contains all the resources pulled from the organization. Each resource type is saved in its respective JSON file. For instance, you will find all your source configurations in the `resources/SOURCE.json` file. ## Push an organization snapshot From the directory containing the target `resources/` folder, run the [`coveo org:resources:push`](https://docs.coveo.com/en/cli#coveo-orgresourcespush) command to upload the local resources to the destination organization. ```bash coveo org:resources:push -o ``` The CLI will return a preview of the changes you're about to apply to the destination organization. You will always be prompted for confirmation before applying any changes to an organization. > **Notes** > > * If you only want to view the changes of a snapshot with no side effect to your organization, use the [`coveo org:resources:preview`](https://docs.coveo.com/en/cli#coveo-orgresourcespreview) command instead. > * After it has applied a snapshot in the destination organization, the CLI deletes the snapshot from that destination organization, to avoid reaching the limit on the number of organization snapshots. ### Handle missing vault entries After running the push command, you might receive a message asking you to transfer vault entries. Vault entries are sensitive and restricted key-value pairs stored in the [Vault Resource of the Coveo Migration API](https://platform.cloud.coveo.com/docs?urls.primaryName=Migration#/Vault). The API uses these entries to migrate sensitive information leveraged by your resources, such as credentials used to [index](https://docs.coveo.com/en/204/) content. You will see this message if your snapshot contains at least one resource that depends on sensitive information missing in the destination organization. This is because sensitive information isn't transferred with the snapshot. The message will look something like the following. ```bash Missing vault entries in destination organization: • some_source-configuration.parameters.ConsumerSecret.value • some_source-configuration.parameters.ConsumerKey.value • some_source-configuration.parameters.AccessTokenSecret.value • some_source-configuration.parameters.AccessToken.value Would you like to try transferring the vault entries from some_source to the destination organization destinationorg? (y/n): ``` In this example, the source `some_source` has four secrets not yet present in the destination organization. If you answer "yes", the CLI will try to transfer missing vault entries from the origin to the destination organization. If the transfer isn't possible, you will be asked to manually populate the missing vault entries. ```bash Would you like to create the missing vault entries in the destination organization destinationorg? (y/n): ``` Answering "yes" to the above question opens a JSON file in your default editor. From there, fill the empty strings with the target vault entry values. ```json { "some_source-configuration.parameters.ConsumerSecret.value": "", "some_source-configuration.parameters.ConsumerKey.value": "", "some_source-configuration.parameters.AccessTokenSecret.value": "", "some_source-configuration.parameters.AccessToken.value": "" } ``` Finally, you should see a confirmation that your snapshot has been applied to the target organization.