---
title: Restoring continuous integration files to the database
related:
  - https://docs.kentico.com/13/developing-websites/setting-up-continuous-integration.md
  - https://docs.kentico.com/13/custom-development/handling-global-events/excluding-content-from-staging-and-integration.md
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

When using [continuous integration](https://docs.kentico.com/13/developing-websites/setting-up-continuous-integration.md), you can get changes from other developers or your source control system by loading XML files into your _CIRepository_ folder. You then need to transfer the corresponding object changes to the database of your Xperience instance. Xperience provides a command line utility that deserializes the files and saves the object data back into the database.

> **Note:** **Warning**
>
> The restore operation  _**deletes**_ any [supported objects](https://docs.kentico.com/13/developing-websites/setting-up-continuous-integration/object-types-supported-by-continuous-integration.md) in the database that do not exist as files in the continuous integration repository. Before you run the restore process, make sure the _CIRepository_ folder contains the required state of your object data.
>
> To avoid loss of local data, you need to maintain the file system repository as a full image of your database – serialize all objects to the file system at the start of development and leave continuous integration enabled. You then need to merge the file content of the _CIRepository_ folder when loading data from another team member or the central source control.

Navigate to the **CMS\bin** folder of your administration project and run **ContinuousIntegration.exe** from the command line with the **-r** parameter.

```csharp

ContinuousIntegration.exe -r

```

The utility deserializes the objects stored in the project's _CIRepository_ folder and creates, overwrites or removes corresponding data in the database (specified by the connection string in the given project's web.config file).

To ensure that the restore process works correctly, you need to _**stop your Xperience applications before running the restore process**_. Otherwise you may encounter the following problems:

- Deadlocks or data inconsistencies if the system attempts to write to the _CIRepository_ folder while data is being restored from the files
- Outdated content in the application's cache if you restore without restarting (can cause inconsistencies in the administration interface or the website's content)

**Note**: If you always rebuild your solution after loading files from the source control, the application stops and starts automatically.

## Rebuilding smart search indexes

Restoring data from the _CIRepository_ folder may create new [smart search indexes](https://docs.kentico.com/13/configuring-xperience/setting-up-search-on-your-website/using-locally-stored-search-indexes/creating-local-search-indexes.md) or cause existing ones to become outdated.

If you wish to automatically keep your site's search functionality up-to-date after continuous integration restore operations, run **ContinuousIntegration.exe** from the command line with the additional **-s** parameter.

```csharp

ContinuousIntegration.exe -r -s

```

When restoring data with the **-s** parameter, the system automatically logs rebuild tasks for:

- Any new search indexes
- All indexes whose indexing configuration was modified by the changes

For example, if a restore operation updates the field search settings of a page type, the restore utility logs rebuild tasks for all page search indexes that include the given page type. The index rebuilds are processed when the application starts up after the restore operation.

> **Note:** **Note**: We do not recommend using the **-s** restore parameter if you have large search indexes with very long rebuild times. In these cases, you can rebuild your indexes manually as required.

## Scripting the restore operation

We recommend setting up a process that runs the restore operation, stops/starts your application and performs any other required actions. For example, you can prepare a [PowerShell](https://docs.microsoft.com/en-us/powershell/scripting/overview) script.

```powershell title="Basic PowerShell example"

# Parameter that specifies the path of your Xperience web project folder (i.e. the CMS subfolder)
param (
    [Parameter(Mandatory=$true)]
    [string]$Path
)

# Creates an 'App_Offline.htm' file to stop the website
"<html><head></head><body>Continuous integration restore in progress...</body></html>" > "$Path\App_Offline.htm"

# Runs the continuous integration restore utility
& "$Path\bin\ContinuousIntegration.exe" -r

# Removes the 'App_Offline.htm' file to bring the site back online
Remove-Item "$Path\App_Offline.htm"

```

The script above is only a basic example that demonstrates the general concept. We recommend that you adjust the script to perform all functions required by your environment. The attached [Restore-CI.ps1](https://docs.kentico.com/docsassets/13/restoring-continuous-integration-files-to-the-database/Restore-CI.ps1) file contains a more complete script that also stops and starts Xperience external services.

> **Info:** **Custom restore solutions**
>
> Alternatively, you can use the Xperience API to implement a custom solution for restoring objects from the file system repository. See [Restoring objects from the file system](https://docs.kentico.com/13/custom-development/serializing-objects-to-xml-using-the-api.md#restoring-objects-from-the-file-system).
