---
title: "Recover a failed import"
slug: "recover-a-failed-import"
abstract: "Recover a failed import by restoring your environment with a recovery package using the Content Hub CLI."
---
# Recover a failed import

If an import fails, entities with dependencies (for example, `Portal.PageComponent` and `Portal.PageDefinition`) are automatically rolled back to their previous state. Other changes from the import are not automatically reverted. To undo those changes, restore your environment using a recovery package.

You can use the recovery package generated during the failed import to restore your environment using the Sitecore [Content Hub CLI](https://doc.sitecore.com/ch/en/developers/cloud-dev/content-hub-cli.html) or you can download the recovery package using the Entities API.

## Recover a failed import using the CLI

To recover a failed import using the CLI:

1. Find the job ID using one of the following methods:
    - In the UI, find the job ID either on the [**Recent processes**](https://doc.sitecore.com/ch/en/users/content-hub/view-recent-processes.html "View recent processes") page or the [**Background processes**](https://doc.sitecore.com/ch/en/users/content-hub/view-background-process-logs.html "View background process logs") page.
    - In the CLI, run the following command:

        ```text
        ch-cli jobs list -f Import
        ```

2. Get the backup order ID for the failed import:

    ```text
    ch-cli jobs report --id <IMPORT_JOB_ID>
    ```

3. Download the recovery package for that backup order:

    ```text
    ch-cli orders fetch --id <BACKUP_ORDER_ID>
    ```

4. Restore the tenant using the recovery package:

    ```text
    ch-cli system import -s "<URL_FROM_FETCH_OR_LOCAL_PATH_TO_PACKAGE>"
    ```

5. Verify that the recovery process has completed successfully:

    ```text
    ch-cli jobs status --id <JOB_ID>
    ```

## Recover a failed import using the Entities API

To recover a failed import using the Entities API:

1. In Sitecore Content Hub, go to the [**Background processes**](https://doc.sitecore.com/ch/en/users/content-hub/view-background-process-logs.html "View background process logs") page and find the failed job import.

2. Next to the failed job import, click **View report**, and copy the `backup_order_id`.

3. Use the [Entities API](https://api-docs.sitecore.com/ch/entities-api/entities/entitybyid) to retrieve the recovery package with the `backup_order_id`.

3. In the returned JSON payload, scroll to the renditions section and locate the `downloadOrder`.
   
    ```json    
     "renditions": { 
        "downloadOrder": [
          {
            "href": "https://<CONTENT_HUB_INSTANCE>/api/delivery/<BACKUP_FILE_KEY>?intent=Download&expires..." 
          }
        ]
    } 
    ```

4. Copy the URL from the `href` attribute and paste it into your browser to download the backup package `.zip` file.

5. [Import the package](https://doc.sitecore.com/ch/en/users/content-hub/import-a-package.html) into your environment.

## Best practices

Follow these best practices to ensure a safe and successful recovery:

- Review error messages in the [simulation summary](https://doc.sitecore.com/ch/en/users/content-hub/create-a-simulation-report-to-review-changes.html "Create a simulation report to review changes") report before proceeding.
- Always use the correct CLI context and ensure you have the necessary permissions.
- Do not skip steps—restoring from an incorrect package or skipping the recovery import can worsen tenant issues.
- Monitor the import job until it completes to ensure successful recovery.