---
title: "Enable Data Archiving"
url: "https://docs.ravendb.net/6.2/data-archival/enable-data-archiving"
version: "6.2"
language: "csharp"
---

# Enable Data Archiving

> Client language: C#.
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

> **Note**
>
> - By default, data archiving is disabled.  
>   To use the archiving feature, you must first **enable** it.
>
> - When configuring the feature,  
>   you can also set the **frequency** at which RavenDB scans the database for documents scheduled for archiving.
>
> - Once enabled, the archiving task runs periodically at the configured frequency,  
>   scanning the database for documents that have been scheduled for archival.  
>   Learn how to schedule documents for archival in [Schedule document archiving](https://docs.ravendb.net/6.2/data-archival/schedule-document-archiving.md).
>
> - In this article:
>   - [Enable archiving - from the Client API](#enable-archiving---from-the-client-api)
>   - [Enable archiving - from the Studio](#enable-archiving---from-the-studio)

## Enable archiving - from the Client API

Use `ConfigureDataArchivalOperation` to enable archiving for the database and configure the archiving task.
**Example**:

### Enable\_archiving

```csharp
// Define the archival configuration object
var configuration = new DataArchivalConfiguration
{
  // Enable archiving
  Disabled = false,

  // Optional: override the default archiving frequency
  // Scan for documents scheduled for archiving every 180 seconds 
  ArchiveFrequencyInSec = 180,
  
  // Optional: limit the number of documents processed in each archival run
  MaxItemsToProcess = 100 
};

// Define the archival operation, pass the configuration 
var configureArchivalOp = new ConfigureDataArchivalOperation(configuration);
  
// Execute the operation by passing it to Maintenance.Send
store.Maintenance.Send(configureArchivalOp);
```

### Enable\_archiving\_async

```csharp
// Define the archival configuration object
var configuration = new DataArchivalConfiguration
{
  // Enable archiving
  Disabled = false,
  
  // Optional: override the default archiving frequency
  // Scan for documents scheduled for archiving every 180 seconds 
  ArchiveFrequencyInSec = 180,
  
  // Optional: limit the number of documents processed in each archival run
  MaxItemsToProcess = 100 
};

// Define the archival operation, pass the configuration 
var configureArchivalOp = new ConfigureDataArchivalOperation(configuration);
  
// Execute the operation by passing it to Maintenance.SendAsync
await store.Maintenance.SendAsync(configureArchivalOp);
```

**Syntax**:

```csharp
public ConfigureDataArchivalOperation(DataArchivalConfiguration configuration)
```

```csharp
public class DataArchivalConfiguration
{
  public bool Disabled { get; set; }
  public long? ArchiveFrequencyInSec { get; set; }
  public long? MaxItemsToProcess { get; set; }
}
```

| Parameter | Type | Description |
| - | - | - |
| **Disabled** | `bool` | `true` - archiving is disabled for the entire database (default).<br />`false` - archiving is enabled for the database. |
| **ArchiveFrequencyInSec** | `long?` | Frequency (in seconds) at which the server scans for documents scheduled for archiving. Default: `60` |
| **MaxItemsToProcess** | `long?` | The maximum number of documents the archiving task will process in a single run (i.e., each time it is triggered by the configured frequency). Default: `int.MaxValue` |

## Enable archiving - from the Studio

![Enable archiving](https://docs.ravendb.net/assets/images/enable-archiving-f5d79db5cbd0509e6598bff543aef75a.png)

1. Go to **Settings > Data Archival**.
2. Toggle on to enable data archival.
3. Toggle on to customize the frequency at which the server scans for documents scheduled for archiving.  
   Default is 60 seconds.
4. Toggle on to customize the maximum number of documents the archiving task will process in a single run.
5. Click Save to apply your settings.

## See also

- [Overview](https://docs.ravendb.net/6.2/data-archival/overview.md)
- [Schedule document archiving](https://docs.ravendb.net/6.2/data-archival/schedule-document-archiving.md)
- [Archived documents and other features](https://docs.ravendb.net/6.2/data-archival/archived-documents-and-other-features.md)
- [Unarchiving documents](https://docs.ravendb.net/6.2/data-archival/unarchiving-documents.md)
- [Overview](https://docs.ravendb.net/6.2/server/configuration/configuration-options.md#settings.json)
- [Database Settings](https://docs.ravendb.net/6.2/studio/database/settings/database-settings.md#view-database-settings)
- [Document Expiration](https://docs.ravendb.net/6.2/server/extensions/expiration.md)
- [Patch By Query](https://docs.ravendb.net/6.2/client-api/rest-api/queries/patch-by-query.md)
