---
title: "Backup Overview"
description: "* Maintaining a proper backup routine ensures that you'd be able to restore your data to its state at chosen points in time."
url: "https://docs.ravendb.net/6.2/server/ongoing-tasks/backup-overview"
version: "6.2"
---

# Backup Overview

> 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."

## Backup Overview

> **Note**
>
> - Maintaining a proper backup routine ensures that you'd be able to restore your data to its state at chosen points in time.
>   Use this overview as an introduction to backing up and restoring your databases.
>
> - The two principal reasons for backing up your database are -
>   - **Securing data** in case catastrophe strikes.
>   - **Freezing data in chosen points in time** to retain access to it in various stages of its existence/development.
>
> - RavenDB's Backup is an **Ongoing task**.
>   - Routinely backing up your data is a fundamental aspect of your database maintenance.  
>     Backup is therefore provided not as a one-time operation, but as an [ongoing task](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/general-info.md)
>     that runs in the background.  
>     It is configured once and then executed periodically according to the defined schedule.
>
> - You can create and configure backup tasks using the [Client API](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/backup-overview.md) or
>   in [Studio](https://docs.ravendb.net/6.2/studio/database/tasks/backup-task.md) navigate from **Tasks** -> **Backups** -> **Create a Periodic Backup**.
>
> - On a [sharded](https://docs.ravendb.net/6.2/sharding/overview.md) database, a single backup task
>   is defined by the user for all shards, and RavenDB automatically defines
>   sub-tasks that create backups per shard.  
>   Read about backups on a sharded database [in the section dedicated to it](https://docs.ravendb.net/6.2/sharding/backup-and-restore/backup.md).
>
> - In this page:
>   - [Backup Type](#backup-type)
>   - [Backup Contents](#backup-contents)
>   - [Backup Scope: Full or Incremental](#backup-scope:-full-or-incremental)
>   - [Backup Name and Folder Structure](#backup-name-and-folder-structure)
>   - [Encryption](#encryption)
>   - [Compression](#compression)
>   - [Retention Policy](#retention-policy)
>   - [Restoration Procedure](#restoration-procedure)

## Backup Type

There are two backup types: [Logical-backup](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/backup-overview.md#logical-backup) (or simply "Backup") and [Snapshot](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/backup-overview.md#snapshot).

#### Logical Backup

A logical backup is a compressed JSON dump of database contents, including documents, index definitions, and [additional data](#backup-contents)
that can be stored in [full](#full-backup) and [incremental](#incremental-backup) backups.

- After a database restore, the dataset is re-indexed by the backed-up index definitions.  
  This can be time-consuming in large datasets.

#### Snapshot

A snapshot is a binary image of the database contents, full indexes, and [additional data](#backup-contents)
at a given point in time.

- Restoration time is reduced because no re-indexing is needed, but more data is transferred during backups.
- [Incremental Snapshot backups](#backup-scope:-full-or-incremental)
  (the changes made since the last backup) **do not incrementally update indexes or change vector data** after the initial complete Snapshot image.

> **Note**
>
> Snapshots are only available for *Enterprise subscribers*.

## Backup Contents

Backed-up data includes both database-level and cluster-level contents, as detailed below.

| Database-level data | [Logical Backup](#logical-backup) | [Snapshot](#snapshot) |
| - | - | - |
| [Documents & Revisions](https://ravendb.net/learn/inside-ravendb-book/reader/4.0/3-document-modeling) | ✔ | ✔ |
| [Attachments](https://docs.ravendb.net/6.2/document-extensions/attachments/what-are-attachments.md) | ✔ | ✔ |
| [Counters](https://docs.ravendb.net/6.2/document-extensions/counters/overview.md) | ✔ | ✔ |
| [Time-Series](https://docs.ravendb.net/6.2/document-extensions/timeseries/overview.md) | ✔ | ✔ |
| [Change Vector data](https://docs.ravendb.net/6.2/server/clustering/replication/change-vector.md#after-restoring-a-database-from-backup) | Change Vectors are not preserved, thus recreated from the beginning upon restore | ✔ |
| [Tombstones](https://docs.ravendb.net/6.2/glossary/tombstone.md) | ✔ | ✔ |
| [Conflicts](https://docs.ravendb.net/6.2/server/clustering/replication/replication-conflicts.md) | ✔ | ✔ |

| Cluster-level data | [Logical Backup](#logical-backup) | [Snapshot](#snapshot) |
| - | - | - |
| [Database Record](https://docs.ravendb.net/6.2/studio/database/settings/database-record.md) | ✔ | ✔ |
| [Compare-exchange values](https://docs.ravendb.net/6.2/client-api/operations/compare-exchange/overview.md) | ✔ | ✔ |
| [Identities](https://docs.ravendb.net/6.2/client-api/document-identifiers/working-with-document-identifiers.md#identities) | ✔ | ✔ |
| [Indexes](https://docs.ravendb.net/6.2/indexes/creating-and-deploying.md) | Index definitions are saved and used to rebuild indexes during database restoration | ✔ |
| [Ongoing Tasks configuration](https://docs.ravendb.net/6.2/studio/database/tasks/ongoing-tasks/general-info.md) | ✔ | ✔ |
| [Subscriptions](https://docs.ravendb.net/6.2/client-api/data-subscriptions/what-are-data-subscriptions.md) | ✔ | ✔ |

## Backup Scope: Full or Incremental

You can set the Backup task to create either **full** or **incremental** backups during its periodical executions.

#### **Full Backup**

A full backup contains **all** current database contents and configuration.

- The creation of a full-backup file normally **takes longer** and **requires more storage space** than the creation of an incremental-backup file.

#### **Incremental Backup**

An incremental backup contains only **the difference** between the current database data and the last backed-up data.

- An incremental-backup file is normally **faster to create** and **smaller** than a full-backup file.

- When an incremental-backup task is executed, it checks for the existence of a previous backup file.  
  If such a file doesn't exist, the first backup created will be a full backup.  
  Subsequent backups will be incremental.

- **A Typical Configuration**  
  A typical configuration would include quick incremental-backup runs that "fill the gaps" between full backups.
  - For example -  
    A **full-backup** task is set to run **every 12 hours**,  
    and an **incremental-backup** task that runs **every 30 minutes**.

## Backup Name and Folder Structure

#### Naming

Backup folders and files are **named automatically**.

- Their names are constructed of:  
  Current Date and Time  
  Backed-up Database Name  
  Owner-Node Tag  
  Backup Type ("backup" or "snapshot")  
  Backup Scope ("full-backup" or "incremental-backup")

- For example:
  - `2018-12-26-16-17.ravendb-Products-A-backup` is the name automatically given to a backup *folder*.
    - "**2018-12-26-16-17**" - Backup Date and time
    - "**Products**" - Backed-up Database name
    - "**A**" - Executing node's tag
    - "**backup**" - Backup type (backup/snapshot)

- `2018-12-26-16-17.ravendb-full-backup` is the name automatically given to the backup *file* inside this folder.
  - "**full-backup**" - For a full backup; an incremental backup's name will state "incremental-backup".

#### Folder Structure

A typical backup folder holds a single full-backup file and a list of incremental-backup files that supplement it.  
Each incremental backup file contains only the delta from its predecessor backup file.

- For example -  
  2018-12-26-09-00.ravendb-full-backup  
  2018-12-26-12-00.ravendb-incremental-backup  
  2018-12-26-15-00.ravendb-incremental-backup  
  2018-12-26-18-00.ravendb-incremental-backup

## Encryption

Stored backup data can be [Encrypted](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/encrypted-backup.md) or Unencrypted.

## Compression

- A backup always consists of a single compressed file.  
  It is so for all backup formats: Full "logical" backup dumps, Snapshot images, and the Incremental backups that supplement both.
- Data is compressed using [gzip](https://www.gzip.org/).

## Retention Policy

By default, backups are not deleted. The backup retention policy sets a retention period,
at the end of which backups are deleted. Deletion occurs during the next scheduled backup task
after the end of the retention period.

- Set retention policy [via API](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/backup-overview.md#backup-retention-policy).
- Set retention policy [via Studio](https://docs.ravendb.net/6.2/studio/database/tasks/backup-task.md#retention-policy).

## Restoration Procedure

To restore a database -

- [Provide RavenDB](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/restore.md#restoring-a-database:-configuration-and-execution)
  with the path to the backup folder.
- To [restore an encrypted database](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/encrypted-backup.md#restoring-an-encrypted-backup)
  you must provide the encryption key.
- RavenDB will search the backup folder and restore the full-backup found in it.
- RavenDB will then restore the incremental-backups one by one, up to and including the last one.  
  You can set `LastFileNameToRestore` to
  [stop restoration](https://docs.ravendb.net/6.2/client-api/operations/maintenance/backup/restore.md#optional-settings)
  at a specific backup file.
