---
title: "Operations: Server: How to Restore a Database from the Backup"
url: "https://docs.ravendb.net/6.2/client-api/operations/server-wide/restore-backup"
version: "6.2"
language: "csharp"
---

# Operations: Server: How to Restore a Database from the Backup

> Client language: C#. Also available for [Java](https://docs.ravendb.net/6.2/client-api/operations/server-wide/restore-backup.java.md), [Node.js](https://docs.ravendb.net/6.2/client-api/operations/server-wide/restore-backup.nodejs.md).
>
> 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."

- To restore a database from its backup, use `RestoreBackupOperation`.
- A backup can also be restored using [Studio](https://docs.ravendb.net/6.2/studio/database/create-new-database/from-backup.md).

## Syntax

```csharp
public RestoreBackupOperation(RestoreBackupConfiguration restoreConfiguration)
```

```csharp
public class RestoreBackupConfiguration
{
  public string DatabaseName { get; set; }

  public string BackupLocation { get; set; }

  public string LastFileNameToRestore { get; set; }

  public string DataDirectory { get; set; }

  public string EncryptionKey { get; set; }
}
```

| Parameters | | |
| - | - | - |
| **DatabaseName** | string | Database name to create during the restore operation |
| **BackupLocation** | string | Directory containing backup files |
| **LastFileNameToRestore** | string | Used for partial restore |
| **DataDirectory** | string | Optional: Database data directory |
| **EncryptionKey** | string | Encryption key used for restore |

## Example

```csharp
RestoreBackupConfiguration config = new RestoreBackupConfiguration()
{
  BackupLocation = @"C:\backups\Northwind",
  DatabaseName = "Northwind"
};
RestoreBackupOperation restoreOperation = new RestoreBackupOperation(config);
store.Maintenance.Server.Send(restoreOperation)
  .WaitForCompletion();
```

## See also

- [Create DB: From Backup](https://docs.ravendb.net/6.2/studio/database/create-new-database/from-backup.md)
- [Create DB: General Flow](https://docs.ravendb.net/6.2/studio/database/create-new-database/general-flow.md)
- [Create DB: Encrypted](https://docs.ravendb.net/6.2/studio/database/create-new-database/encrypted.md)
- [The Backup Task](https://docs.ravendb.net/6.2/studio/database/tasks/backup-task.md)
- [Restore](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/restore.md)
- [What Is Smuggler](https://docs.ravendb.net/6.2/client-api/smuggler/what-is-smuggler.md)
- [Backup](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/backup-overview.md)
- [Backup Overview](https://docs.ravendb.net/6.2/server/ongoing-tasks/backup-overview.md)
- [Migration](https://docs.ravendb.net/6.2/migration/server/data-migration.md)
